|
-
Apr 25th, 2002, 09:51 AM
#1
Thread Starter
Lively Member
Sort a MSHFlexGrid using Row and RowSel
Scenario:
I want to sort a mshflexgrid within a specified range of rows, which is everything but the last row. The last row of the grid, I am using for the totals and therefore do not want to sort. I am sorting using the last column which is the total for each row.
mshflexgrid.row = 1 'Begin Row selection
mshflexgrid.rowsel = mshflexgrid.rows-2 'End row selection
mshflexgrid.col = mshflexgrid.cols-1 'selected column
mshflexgrid.sort = flexSortNumericDescending
What I am getting:
The flexgrid gets sorted but the last total row gets sorted as well and because it is the total and has the highest number, it is placed on the top.
What I am looking for:
I want not to sort the last row of the flex.
Thanks in advance,
-
Apr 25th, 2002, 10:24 AM
#2
Thread Starter
Lively Member
-
Apr 25th, 2002, 10:27 AM
#3
Fanatic Member
save the last row values to an array,
cut the row,
sort,
add the row to the end.
hey, it works.
-
Apr 25th, 2002, 10:31 AM
#4
Thread Starter
Lively Member
Ok, I will try that. But, I thought the idea behind RowSel is to be able to select a range of rows for sorting and stuff like that. If anyone have used it before then I would like to see a sample code.
Thank you for the reply
-
Apr 25th, 2002, 10:46 AM
#5
Fanatic Member
I guess you are correct. I didn't know you could sort a range of rows.
I did this:
VB Code:
Private Sub Command6_Click()
xgrid.Row = 2
xgrid.RowSel = 8
xgrid.Sort = 2
End Sub
I had a grid with numbers 1,2,3,4,5..10
and it reversed them, only within the range.
double check that:
-you set the .row AND the .rowsel
-you set the correct .col
-remember that rows are numbered 0 to .count-1
it should work for ya.
-
Apr 25th, 2002, 10:52 AM
#6
Thread Starter
Lively Member
I thought so. If you look into my original post, I have a sample code of what I tried. I am mainly concern about
mshflexgrid.rowsel = mshflexgrid.rows-2
The reason i subtracted two is not to include the last row, which is grid.rows-1. But, no matter what number I put there (I just tried putting 3, 4 and like), it still sorts my last row.
-
Apr 25th, 2002, 10:59 AM
#7
Thread Starter
Lively Member
JPicasso, thanks for replying to my post. I did find the solution using the same code I had before, the only difference is that I changed the position of the statement. I set .Row and .Col before I set .RowSel and it works. I thought, setting .Row after .RowSel would reset .RowSel but apparently .Col also resets .RowSel (Don't understand why though!). Hey, you learned something new and i did too..
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|