how to prevent sorting in DataGridView? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this questionhow to prevent sorting in DataGridView
?
Winforms?
for (int i = 0; i < this.dataGridView1.ColumnCount - 1; i++)
{
this.dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.Programmatic;
}
I'll assume you mean sorting in a WPF DataGrid: Set CanUserSortColumns="False"
.
I am assuming you are talking about web page grid view
<asp:GridView AllowPaging=false ...
Or if it's a WinForms DataGridView you can set the sortmode of the columns as:
Column1.SortMode = NotSortable
精彩评论