Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSFlexGrid sort arrow

Status
Not open for further replies.

BeejCyr

MIS
Aug 1, 2002
49
US
I have just about finished a program where everything revolves around a MSFlexGrid control. I would like some way to indicate to the user on which column and direction the data is sorted. In other MS programs (like Outlook) there is a small arrow that points up or down in the column header that grid is sorted on. How, if possible at all, is this done with Flexgrid?
 
I don't know of anything that can be done in the MSFlexgrid to achieve t he effect that you are looking for.

However you can add a floating image or picture control and place it on one side of the column header that is used in the sort. You could even have a contolarray of pictures and use the index property to set one visible and the rest not. Doing this will also lead to other issues, such as if the columns are resized then you will have to move the picture.

Something to think about anyway. Thanks and Good Luck!

zemp
 
Here's a good start for you. You place to picturebox controls on the form with the up/down arrows, then set the cellpicture for the column header that you're sorting.

I say it's only a start, because you still need to do the sort in the beginning and play with the alignment properties to get the text and picture to look like you want, but his will show you how to put the picture into the cell.


Dim nSortCol As Integer
Dim nSortOrder As Integer

Private Sub MSFlexGrid1_DblClick()
With MSFlexGrid1
If .MouseRow = 0 Then
.Row = 0
'New Col - Remove old pic, sort ascending
If .MouseCol <> nSortCol Then
.Col = nSortCol
Set .CellPicture = Nothing
.Col = .MouseCol
nSortOrder = flexSortGenericAscending
'Same Col - Reverse sort
Else
If nSortOrder = flexSortGenericAscending Then
nSortOrder = flexSortGenericDescending
Else
nSortOrder = flexSortGenericAscending
End If
End If
'Sort column, set picture
.Sort = nSortOrder
If nSortOrder = flexSortGenericAscending Then
Set .CellPicture = picUP.Picture
Else
Set .CellPicture = picDown.Picture
End If
nSortCol = .Col
End If
End With
End Sub
 
THanks guys. I will try out the picture box idea and see if it fits in to the way I envisioned the program to look.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top