I have a DataGridView with 3 rows.
I am adding a fourth row programmatically.
Is there any way to prevent the user from select开发者_开发问答ing the three rows after I add the fourth row.
Thanks a ton everyone
DataGridView1.Rows[0].ReadOnly = true;
DataGridView1.Rows[1].ReadOnly = true;
DataGridView1.Rows[2].ReadOnly = true;
This will make sure that the users cannot edit the data on the first 3 rows.
Or something like...
On the Cell_Click event,
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if ((e.RowIndex == 0) || (e.RowIndex == 1) || (e.RowIndex == 2))
{
dataGridView1.ClearSelection();
}
}
Do you only want them selecting and acting on the row you added? If so, you don't need the grid for that, you can assume whatever row they're on is the one you want them to be on, even if they're not.
精彩评论