Título da Dica: Ordenando o FlexGrid com o clique na coluna
Postada em 29/1/2003 por Felipe Private Sub Form_Load() Dim Str As String Dim i As Integer Dim j As Integer
i = 0: j = 0 MSFlexGrid1.Rows = 1 Randomize For i = 1 To Int(Rnd() * 10) + 1 Str = "" For j = 1 To 10 Str = Str & Chr(65 + Int(Rnd() * 26)) Next MSFlexGrid1.AddItem Int(Rnd() * 100) & vbTab & Str Next End Sub
Private Sub MSFlexGrid1_Click() Call FlexSort("A") End Sub
Private Sub MSFlexGrid1_DblClick() Call FlexSort("D") End Sub
Sub FlexSort(Mode As String) If MSFlexGrid1.Row = 1 Then If MSFlexGrid1.MouseCol = 0 Then MSFlexGrid1.Col = 0 If Mode = "A" Then MSFlexGrid1.Sort = flexSortNumericAscending Else MSFlexGrid1.Sort = flexSortNumericDescending End If ElseIf MSFlexGrid1.MouseCol = 1 Then MSFlexGrid1.Col = 1 If Mode = "A" Then MSFlexGrid1.Sort = flexSortStringAscending Else MSFlexGrid1.Sort = flexSortStringDescending End If End If End If End Sub