
How to sort a column in flexgrid when user click a column heading on the fixed row?
This is modified from the example provided in the help ... works for me.
Obviously you want extend this to assure the proper sort type is applied
against the column data types.
Option Explicit
Private Sub Form_Load()
Dim i As Integer
MSFlexGrid1.Cols = 3 ' Create three columns.
For i = 1 To 5
MSFlexGrid1.AddItem ""
MSFlexGrid1.Col = 2
MSFlexGrid1.TextMatrix(i, 1) = SomeName(i)
MSFlexGrid1.TextMatrix(i, 2) = Rnd() * 1000
Next i
End Sub
Private Function SomeName(i As Integer) As String
Select Case i
Case 1: SomeName = "Ann"
Case 2: SomeName = "Glenn"
Case 3: SomeName = "Sid"
Case 4: SomeName = "Anton"
Case 5: SomeName = "Sandy"
End Select
End Function
Private Sub MSFlexGrid1_Click()
Static sortMode
If MSFlexGrid1.Row = 1 Then
If MSFlexGrid1.Col > 1 Then
If sortMode = flexSortNumericDescending Then
sortMode = flexSortNumericAscending
Else: sortMode = flexSortNumericDescending
End If
MSFlexGrid1.Sort = sortMode
End If
End If
End Sub
--
Randy Birch, MVP Visual Basic
http://www.mvps.org/vbnet/
http://www.mvps.org/ccrp/
| Is there a way to sort a particular column in MS flexgrid
| when user click the column
| heading on a fixed row?
|
| I know sort method is supported by the flexgrid, but
| clicking the fixed row does not
| seem to toggle the click event of the control.
|
| Thanks in advance to any help.
|
| C.J. Yap
|
|
|
| * Sent from RemarQ http://www.remarq.com The Internet's Discussion Network
*
| The fastest and easiest way to search and participate in Usenet - Free!