private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{
if (e.ColumnIndex==2) // 2代表第二列
{
e.Cancel = true;
}
}
{
if (e.ColumnIndex==2) // 2代表第二列
{
e.Cancel = true;
}
}
本文介绍了一段C#代码,该代码演示了如何在DataGridView控件中禁止用户编辑特定列(此处为第二列)。通过在CellBeginEdit事件中设置e.Cancel属性为true来实现这一功能。
1691

被折叠的 条评论
为什么被折叠?