Tôi có một datagridview winforms mà dường như luôn luôn có ít nhất một hàng được chọn tất cả các thời gian. Tôi không quan tâm đến việc có thể chọn các hàng thực sự, tôi chỉ cần người dùng có thể chọn hộp kiểm trong cột 1. Bất kỳ ý tưởng nào tại sao luôn có ít nhất 1 hàng được chọn? Làm cách nào để ngăn chặn điều này? Điều đó có ảnh hưởng đến khả năng chọn hộp kiểm trong cột 1 không?C# WinForms DataGridView - Hàng liên tục được chọn!
Dưới đây là các thiết lập DataGridView tôi:
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
this.dataGridView1.DefaultCellStyle.ForeColor = Color.Black;
this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dataGridView1.MultiSelect = false;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.RowsDefaultCellStyle.BackColor = Color.WhiteSmoke;
this.dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.LightGray;
this.dataGridView1.ColumnCount = 0;
colSelect = new DataGridViewCheckBoxColumn();
colSelect.HeaderText = "Select Message";
colSelect.Width = 90;
this.dataGridView1.Columns.Insert(0, colSelect);
this.dataGridView1.Columns[0].DataPropertyName = "msgSelect";
khá chắc chắn điều đó không đúng ........ – Goober
Thật sao? Lý do tại sao có một hàng được chọn là bởi vì đó là những gì chế độ lựa chọn của bạn được thiết lập để! Do đó để ngừng chọn "một hàng", bạn cần phải thay đổi nó ... – Calanus
Tôi không nghĩ rằng bạn hiểu câu hỏi của Calanus. Anh ta muốn biết làm thế nào anh ta có thể ngăn chặn DataGridView từ việc chọn hàng đầu tiên trong danh sách theo mặc định. – James