开发者

how to set a DataGridViewColumn cells to unselectable?

开发者 https://www.devze.com 2023-01-14 18:02 出处:网络
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 d

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

0

精彩评论

暂无评论...
验证码 换一张
取 消