hihi..

i have this exmaple code coded on this forum , and it work very well for flexgrid. but when i start to used it on MSHFLEXGRID it become malfunction. What is the problem on this code. when i click on the header, everthing started to sort. it turn out very messy. When i set the properties header, i was thrown with error for the "out of range" msg. Sorry for the lengthly code.

VB Code:
  1. Private Sub Form_Load()
  2.  With presentation_search.presentationCollection_grid
  3.     .TextMatrix(0, 1) = "Presentation ID"
  4.     .TextMatrix(0, 2) = "Presentation Name"
  5.     .TextMatrix(0, 3) = "Presentation Type"
  6. end with
  7. end sub
  8.  
  9. Private Sub presentationCollection_grid_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  10.  
  11.   ' If this is not row 0, do nothing.
  12.     If presentationCollection_grid.MouseRow <> 0 Then
  13.     Exit Sub
  14.     End If
  15.     ' Sort by the clicked column.
  16.     SortByColumn presentationCollection_grid.MouseCol
  17. End Sub
  18. ' Sort by the indicated column.
  19. Private Sub SortByColumn(ByVal sort_column As Integer)
  20.     presentationCollection_grid.Visible = False
  21.     presentationCollection_grid.Refresh
  22.     ' Sort using the clicked column.
  23.     presentationCollection_grid.Col = sort_column
  24.     presentationCollection_grid.ColSel = sort_column
  25.     presentationCollection_grid.Row = 0
  26.     presentationCollection_grid.RowSel = 0
  27.     ' If this is a new sort column, sort ascending.
  28.     ' Otherwise switch which sort order we use.
  29.     If m_SortColumn <> sort_column Then
  30.         m_SortOrder = flexSortGenericAscending
  31.     ElseIf m_SortOrder = flexSortGenericAscending Then
  32.         m_SortOrder = flexSortGenericDescending
  33.     Else
  34.         m_SortOrder = flexSortGenericAscending
  35.     End If
  36.     presentationCollection_grid.Sort = m_SortOrder
  37.     ' Restore the previous sort column's name.
  38.     If m_SortColumn >= 0 Then
  39.         presentationCollection_grid.TextMatrix(0, m_SortColumn) = Mid$(presentationCollection_grid.TextMatrix(0, m_SortColumn), 3)
  40.     End If
  41.     ' Display the new sort column's name.
  42.     m_SortColumn = sort_column
  43.     If m_SortOrder = flexSortGenericAscending Then
  44.         presentationCollection_grid.TextMatrix(0, m_SortColumn) = "> " & presentationCollection_grid.TextMatrix(0, m_SortColumn)
  45.     Else
  46.         presentationCollection_grid.TextMatrix(0, m_SortColumn) = "< " & presentationCollection_grid.TextMatrix(0, m_SortColumn)
  47.     End If
  48.  
  49.     Debug.Print sort_column; presentationCollection_grid.Col; m_SortColumn '@
  50.     ' Display the FlexGrid.
  51.     presentationCollection_grid.Visible = True
  52. End Sub

???
ocw