How to sort a column in flexgrid when user click a column heading on the fixed row? 
Author Message
 How to sort a column in flexgrid when user click a column heading on the fixed row?
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.*-*-*.com/ The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!



Thu, 17 Jan 2002 03:00:00 GMT  
 How to sort a column in flexgrid when user click a column heading on the fixed row?

The Click event should fire even on fixed rows. The MouseCol and MouseRow properties should tell you in which row and column the user clicked. You need to set Col and ColSel properties to be the column (or range of columns) by which you want to sort. You then set the Row and RowSel properties to be the range of rows you want to sort. Finally set the Sort property to one of the flexSort constants such as flexSortStringNoCaseAsending. If you use flexSortCustom (e.g. for a Date sort) you must write code in the Compare event to say how the values are to be compared. (Read the help file for the Compare event.)

Regards,
Simon Jones
MillStream Designs Ltd
Independent IT Consultants


  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.



Fri, 18 Jan 2002 03:00:00 GMT  
 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!



Fri, 18 Jan 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Column headings in multi-column combo box

2. Unable to Highlight Flexgrid Fixed Column/Cell

3. Access 97 Column Head Click

4. MSFlexGrid:How to intercept click on a column heading

5. Access 97 Column Head Click

6. ListView Column Head Clicked?

7. FlexGrid Merge Columns: Row/Column selection inconsistant?!?!

8. Sorting a column of a flexgrid...

9. Flexgrid - Sorting Columns?

10. Sorting Fixed Columns in MSFLEXGRID

11. sorting a listview by clicked column

12. Sorting the content of list view on clicking column headers

 

 
Powered by phpBB® Forum Software