Guest User

Untitled

a guest
Jan 15th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. Dim direction As SortOrder
  2. .
  3. .
  4. .
  5.  
  6. direction = DataGridView1.SortOrder
  7. MsgBox(direction.ToString())
  8.  
  9. columnXY = DataGridView1.SortedColumn
  10. *' if no column set for sort use third one *
  11. If columnXY Is Nothing Then
  12. columnXY = DataGridView1.Columns(2)
  13. End If
  14.  
  15. Dim SetSortOrder As ListSortDirection
  16. Dim GridSortOrder As SortOrder
  17. GridSortOrder = DataGridView1.SortOrder
  18.  
  19. If GridSortOrder = Windows.Forms.SortOrder.Ascending Then
  20. SetSortOrder = ListSortDirection.Ascending
  21. ElseIf GridSortOrder = Windows.Forms.SortOrder.Descending Then
  22. SetSortOrder = ListSortDirection.Descending
  23. ElseIf GridSortOrder = Windows.Forms.SortOrder.None Then
  24. SetSortOrder = ListSortDirection.Ascending
  25. Else : GridSortOrder = ListSortDirection.Ascending
  26. MsgBox("not good")
  27. End If
  28.  
  29. DataGridView1.DataSource = datasetXY.Tables(0)
  30. DataGridView1.Sort(columnXY, SetSortOrder)
Add Comment
Please, Sign In to add comment