Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Giving code to a grid column at runtime.
Message
From
05/08/1999 08:13:37
Kenneth Downs
Secure Data Software, Inc.
New York, United States
 
 
To
05/08/1999 07:18:49
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00250099
Message ID:
00250112
Views:
22
Tim,

If you don't know the number of columns until runtime, then can I guess that you are building the grid at run-time? If so, then this approach might be of help.

First, you cannot add code to an object at run-time. So, if you need code in the grid header (say for click or double-click) you can't put it in at run-time.

Therefore, you want to subclass the header. Subclassing the header has its own problems because you can't modify the subclassed header later on. The best way to minimize these problems is like so:

1. Create a form
2. Drop on a grid and put in one column
3. If you're going after the Click method, put this code in the Click method of the column header: =MyColumnClickMethod(this).
4. Run the form with DO FORM MyForm NAME oForm
5. Save the column with oForm.Grid1.Column1.header1.SaveAsClass(....)

You now have a column class that calls out to MyColumnClickMethod.prg. Code up that PRG for the desired behavior. If you ever want to change the column's click behavior, you just change the PRG and you don't have to mess with the column any more.

Now, at run-time, when you build the grid, you might use something like this:
Thisform.Grid1.ColumnCount = NumberOfColumns
WITH MyForm.MyPageFrame...etc...Grid1
  FOR i = 1 TO NumberOfColumns
    .columns(i).removeobject("header1")
    .columns(i).addobject("header1","MyHeaderClass")
  ENDFOR
ENDWITH
Hope this helps!

>Hi!
>
>I want to set the
>grid.columnX.header1.click()
>
>code at runtime How can I do this?
>
>I tried....
>
>&ctheControl="thisform.browselist.column"+alltrim(str(i))+'.header1.WriteMethod("click","thisform.sortcolumn")'
>&ctheControl
>
>All I really need is for this click event to have the code...
>thisform.sortcolumn
>
>for all columns..
>
>The problem is I don't know how many columns there are until runtime..
>
>I hope I'm clear..
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform