Sort problem with MSHFlexgrid [Resolved]
I get an runtime error "Method 'Sort' of IMSHFlexgid failed" using the following code. I have used this in another project and it worked there. What am I missing here?
Code:
.SelectionMode = flexSelectionByColumn
.Col = 0
.ColSel = 0
.Row = 1
.RowSel = .Rows - 1
.Sort = flexSortStringAscending
Re: Sort problem with MSHFlexgrid
Your example works fine for me under VS SP6. Maybe you have a corrupt vbp or ???
VB Code:
Option Explicit
Private Sub Command1_Click()
With MSHFlexGrid1
.SelectionMode = flexSelectionByColumn
.Col = 0
.ColSel = 0
.Row = 1
.RowSel = .Rows - 1
.Sort = flexSortStringAscending
End With
End Sub
Private Sub Form_Load()
With MSHFlexGrid1
.AddItem "test3"
.Row = 2
.AddItem "test2"
.Row = 3
.AddItem "test1"
End With
End Sub
Re: Sort problem with MSHFlexgrid
RobDog888,
After much trial and error(s), I found the source of the problem. It was in another section of code but this problem did not occur until I added those lines of code.
I found that this line caused the problem:
.ColHeader(0) = flexColHeaderOn
for some reason you can not sort with a column header on.
Re: Sort problem with MSHFlexgrid
odd...I've done it before so it cant be that
Re: Sort problem with MSHFlexgrid
c00lryguy,
Well, I commented out lines of code until it worked, then uncommented the lines until it stoped working and that line was the one. It could be a combination of lines but this is the one that stoped my code from working.
Re: Sort problem with MSHFlexgrid [Resolved]
I also had this strange problem, changing old applications of VB6.
ColHeader(0) = flexColHeaderOff before sorting did the trick.
thanks randem