zl程序教程

您现在的位置是:首页 >  其它

当前栏目

怎么让datagridview中的某一行不可编辑

怎么 编辑 不可 一行 DataGridView
2023-09-11 14:16:45 时间
可以用一个不是很“正统”的办法:

private void dataGridView1_RowEnter(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == 2)
dataGridView1.ReadOnly = true;
else
dataGridView1.ReadOnly = false ;
}

这样第二行就不可以编辑了,其它行可以。