Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Click Grid control header to sorting the data in column
Message
 
 
To
10/10/2002 12:24:53
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00708196
Message ID:
00710732
Views:
15
Hi Marcia,

Thanks for your reply.

I am not very good in OOP or create classes in VFP.
I had questions below:

Add a custom method called SetOrder to your grid class. This code goes in SetOrder():

LPARAMETERS tcTag

*** Make sure a valid tag name was passed
IF ! EMPTY( tcTag )
WITH This
*** Make sure it really is a tag for the grid's RecordSource
IF IsTag( tcTag, .RecordSource )
lnRecNo = RECNO( .RecordSource )
*** Go ahead and set the order for the table
SELECT ( .RecordSource )
SET ORDER TO ( tcTag )
.SetFocus()
IF lnRecNo # 0
GO lnRecNo IN ( .RecordSource )
ENDIF
ENDIF
ENDWITH
ENDIF

It means, create a own custom grid class. Using project manager, classes tab add in the new grid class.
After press the new button, prompt a new class dialog box.
class name = myGrid
base on = grid
store in = c:\myProject\my_grid_class

I using the VFP menu Class-New Method... to add in the new method call "setorder".

Is the way to create the grid class? If this correct, I had created and follow all the way you asked. I tried using debuger, I found out the order is changed but the grid data not change. I think I had make some mistake in some way.

I try to created a normal grid control in a form and set the recordsource property as "tablename" and grid column1, controlsource as "ponum". Set the tag property to "1"


The grid header click method I put the code as:

IF this.Tag = "1" then
SET ORDER TO ponum asce
this.Tag = "2"
ELSE
SET order to ponum desc
this.Tag = "1"
ENDIF

GO top

thisform.grid1.Refresh(.t.)

The grid1 can display data follow the change of order in ascending or descending after click the grid header.

Currently I solved my problem but I am not apply the classes way in VFP.

Very much appreciated on your effort in help. TQ.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform