I have a datagridview winforms that always has at least one row selected all the time. I'm not interested in the ability to select rows in fact, I just need the user to be able to check the box in column 1. Any ideas why at least 1 row is always selected? How can I prevent this? Will this affect the ability to select a check box in column1?
The following are the settings for Datagridview:
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";
Goober
source share