how to set a DataGridViewColumn cells to unselectable?
in C# 4.0 (Visual Studio 2010), i have a Windows Form DataGridView that must be multiselect, and i开发者_如何学Got has a specified Column that i don't want its cells to be selectable. what should i do?
i found that there's no property or style to do that, so we should handle it in someway like this:
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].Name == mySpecifiedColumn.Name)
dataGridView1.CurrentCell.Selected = false;
}
thanks.
If you set the DataGridView properties of the highlighted colors to the same as un-selected, it will appear as if you have not selected the cell
精彩评论