我正在通过datagridview列标题对我的绑定源进行排序,如下所示:
Private Sub DataGridView1_ColumnHeaderMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView1.ColumnHeaderMouseClick
Dim p = DataGridView1.Columns(e.ColumnIndex).HeaderText
If DataGridView1.SortOrder = SortOrder.Descending Then
BindingSource1.Sort = p + " DESC"
ElseIf DataGridView1.SortOrder = SortOrder.Ascending Then
BindingSource1.Sort = p + " ASC"
End If
' The Sorted View converted to DataTable and then assigned to table object.
End Sub
我想要做的是对bindingsource进行排序,记住新的排序顺序而不是清除排序。如果我没有清除排序状态,则状态总是设置为升序或降序,这会导致newley添加的行按顺序排列(我不想要)。有什么想法吗?