Ever wonder how to get the MSFlexGrid to have sorting behavior common inmany Windows applications? That is to say when you double-click on acolumns header it sorts ascending. Double-click again and it sortsdescending. The following code demonstrates the basic modificationsnecessary to make this work. Note: In this sample flexSortGenericAscendingand flexSortGenericDescending are used. Of course you can modify this tosort more specifically based on the column.
=====================================================================Prerequisites: Add a grdInformation to your form and populate it.=====================================================================Private mintMyRow As Integer 'Holds Last RowPrivate mintMyCol As Integer 'Holds Last ColPrivate mintLastSort(8) As Integer 'Array with column's lastsort value----------------------------------------------------------------------------Private Sub grdInformation_DblClick() If mintMyRow = 0 Then 'On header row? If mintLastSort(mintMyCol) = 1 Then 'Already sorted ascending? grdInformation.Sort = 2 mintLastSort(mintMyCol) = 2 'Generic Descending Else grdInformation.Sort = 1 mintLastSort(mintMyCol) = 1 'Generic Ascending End If End If End Sub----------------------------------------------------------------------------Private Sub grdInformation_MouseDown(Button As Integer, Shift As Integer, xAs Single, y As Single) mintMyRow = grdInformation.MouseRow mintMyCol = grdInformation.MouseCol End Sub