GridView.Sorted (gb.qt4)
Property Sorted As Boolean
Depuis 3.1
Return or set if clicking on a column header toggles the sort indicator.
Sorting the data is not done automatically. It must be done by user code.
Following is an example of how sorting might be accomplished within the GridView
Sort event.
Example
Public Sub GridView1_Sort()
Dim Values, ValueSorted As New String[]
Dim Nx, iNx As Integer
' Load sort column into string array
For Nx = 0 To GridView1.Rows.Max
Values.Add(GridView1[Nx, GridView1.Columns.Sort].Text)
Next
' Copy values to new array and sort it based on status of sort indicator
ValueSorted = Values.Copy()
ValueSorted.Sort(IIf(GridView1.Columns.Ascending, gb.Ascent, gb.Descent))
' Iterate through table swapping appropriate values
For Nx = 0 To ValueSorted.Max
For iNx = 0 To GridView1.Columns.Max
Swap GridView1[Nx, iNx].Text, GridView1[Values.Find(ValueSorted[Nx], 0, Nx), iNx].Text
Next
' Pick up new order to preserve proper handling of indexing and duplicate values
Values.Clear()
For iNx = 0 To GridView1.Rows.Max
Values.Add(GridView1[iNx, GridView1.Columns.Sort].Text)
Next
Next
GridView1.Refresh()
End
The above can also be applied to a
TableView.