VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



MSHFlexGrid Sort routine

by Greg Thomas (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 21st May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

MSHFlexGrid Sort routine

API Declarations


Private iCol As Integer

Public Enum SortOrder
SortNone = 0
GenericAscending = 1
GenericDescending = 2
NumericAscending = 3
NumericDescending = 4
NoCaseAsending = 5
NoCaseDescending = 6
StringAscending = 7
StringDescending = 8
End Enum

Rate MSHFlexGrid Sort routine



  '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  'NAME:     flxgDisplay_MouseDown
  'DESC:     Work around for sorting flex grids where the user needs the
  '          selection to be by row.  Code finds if top column has been
  '          selected then determines what row and sorts accordingly.
  '          Works okay for dates up to the month (mm/dd/yyyy).
  'CREATED:  Greg Thomas
  'UPDATED:
  '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Dim lWidth As Long
  Dim i As Integer
  
  On Error Resume Next
  
  'Initialize
  lWidth = 0
  
  With flxgDisplay
    If y < .RowHeight(.Row) Then 'Has the fixed row been selected
        
      For i = 0 To .Cols - 1 'loop through cols to find what col was selected
         lWidth = lWidth + .ColWidth(i)
         If x < lWidth Then
            .Col = i
         Exit For
         End If
      Next i
        
      If .Col = iCol Then   'Sort grid with toggle constant
      If Not bDescending Then
        .Sort = SortOrder.GenericDescending
        bDescending = True
      Else
        .Sort = SortOrder.GenericAscending
        bDescending = False
      End If
      Else 'Default for new column selection
        .Sort = SortOrder.GenericAscending
        bDescending = False
      End If
    
      'Set variable to what was selected in case user selects again
      iCol = .Col
       
      'Force 1st row selection to clean up grid -- Control Prop should be set to Highlight always
      .ColSel = .Cols - 1
      .RowSel = 1
   
  End If
End With
  
End Sub

Download this snippet    Add to My Saved Code

MSHFlexGrid Sort routine Comments

No comments have been posted about MSHFlexGrid Sort routine. Why not be the first to post a comment about MSHFlexGrid Sort routine.

Post your comment

Subject:
Message:
0/1000 characters