losingsleeep
losingsleeep

Reputation: 1889

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 it has a specified Column that i don't want its cells to be selectable. what should i do?

Upvotes: 1

Views: 5811

Answers (2)

NattyMan0007
NattyMan0007

Reputation: 103

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

Upvotes: -3

losingsleeep
losingsleeep

Reputation: 1889

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.

Upvotes: 5

Related Questions