dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Sep 13, 2000

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Sorting MSFlexGrid

Ever wonder how to get the MSFlexGrid to have sorting behavior common in many Windows applications? That is to say when you double-click on a columns header it sorts ascending. Double-click again and it sorts descending. The following code demonstrates the basic modifications necessary to make this work. Note: In this sample flexSortGenericAscending and flexSortGenericDescending are used. Of course you can modify this to sort more specifically based on the column.

 
=====================================================================
Prerequisites:  Add a grdInformation to your form and populate it.
=====================================================================
Private mintMyRow As Integer            'Holds Last Row
Private mintMyCol As Integer            'Holds Last Col
Private mintLastSort(8) As Integer      'Array with column's last
sort 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, x
As Single, y As Single)
  
  mintMyRow = grdInformation.MouseRow  
  mintMyCol = grdInformation.MouseCol  
End Sub
Steve Guthrie
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date