views:

53

answers:

1

Hi there!

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!

+2  A: 

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!).

Yogesh