How to change the behavior of the DataGridView when clicking a column?
When I click a column of the DataGridView control, the control sorts all the data according to the column.
Is it possible to disable this function? (Actually I want to select the whole column as in Excel or Word tables.)
Thanks开发者_运维知识库!
To disable sorting in the grid, all you need to is to set the SortMode
property of each column to DataGridViewColumnSortMode.NotSortable
, like this:
foreach (DataGridViewColumn column in dataGridView.Columns)
{
column.SortMode = DataGridViewColumnSortMode.NotSortable;
}
As for the full column selection, that functionality is not present. Making it work will need quite some work (if it is possible at all, which I doubt is anyways!).
精彩评论