1

如何确定 aDataGridView是否已排序?我需要获得一个布尔值。

If isDgSorted
 -Do something
else
 -Do something

有什么建议么?

4

2 回答 2

2

DataGridView.SortOrder 属性

获取一个值,该值指示 DataGridView 控件中的项是按升序还是降序排序,还是不排序。

Dim Col1 As DataGridViewColumn = DataGridView1.SortedColumn
'If Col1 is null, then the DataGridView is not currently sorted. 

所以你的结果看起来像这样:

If DataGridView1.SortedColumn Is Nothing Then
    'Isn't sorted
Else
    'It is sorted
End If

有关更多信息,Microsoft 在此处进行了更详细的解释。

于 2013-07-16T13:32:44.777 回答
0

您可以使用:

Private Sub dataGridView_ColumnHeaderMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles DataGridView.ColumnHeaderMouseClick
    Select Case e.ColumnIndex
        Case 0
            'handles first column being clicked
        Case 1
            'handles second column being clicked
        Case 3
            'handles third column being clicked and so on
    End Select
End Sub
于 2013-07-16T11:39:45.183 回答