Can anyone tell me if I can do multiple column sort on MSHFlexgrid? I have done single column sort but not multiple. I cannot find any reference. Thanks in advance.
Do you mean you want to sort on say, column 2 with column 4 as a sub-sort? A bit like in Excel where it says 'Sort on column A... then Column B...' and so on?
If so, then MSFlexGrid doesn't do that but you could do it programatically. I would do the following:
1. Create a hidden listbox somewhere off-screen and set it to Sorted=True
2. Go through your grid one row at a time. The aim is to create a string which contains the following:
{Data from first column you want to sort on}
{chr$(1)}
{Data from second column you want to sort on}
{chr$(2)}
{Data from column 1}
{chr$(1)}
{Data from column 2}
{chr$(1)}
{Data from column 3} etc...
Add the string to the list and move on to the next row. Wash, rinse, repeat until all rows have been added.
3. Repopulate the grid using the data from the list. Take each list item and find the chr$(2) character within the data:
a& = instr(List1.list(b&), chr$(2))
Take everything after the a&th character and add it into each column, using chr$(1) as a delimiter, ignoring everything before the a&th character (that was just used to sort it correctly).
Andy,
I have not tried this out yet but it makes sense and it should work. Using a listbox to do the sorting is a neat idea which I never tried before. I will try it out and let you know how it worked. Thanks a million...
Andy,
I hope you that you would'nt mind but I found out that I did not do an actual multiple sort when I tested the code that you recommended. I found out that the last part, which is populating the flexgrid back, was not working properly. I tried to correct it to no avail. Would you mind showing me a sample code how to do the "instr" loop to re-populate the grid. I will appreciate any help you can give me....
Using the MsFlexgrid Sort Property, i doesnt sort the value after ":", i want this to be sort after ":" too..
Thanks a lot in Advance
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.