VFP80 SP1 on XP
I have a basegrid in MyClass.
I have added it to a form. When I run the form, I programmatically want to add a column and a Click() event to that column. I do not understand the Help screens on this issue. Anyone have a simple example.

TIA

Re: Adding events by Thierry

Thierry
Sat Jul 31 14:25:00 CDT 2004

Hi,

Create a Form.ColumnClick méthod.

Then, in order to add a column :

WITH thisform.grid1
.columnCount = .columnCount +1

BINDEVENT(.columns(.columnCount).controls(1),"click",thisform,"ColumnClick")
ENDWITH

controls(1) is for Column Header
Use controls(2) instead for the TextBox

--
Thierry


"Cowboy" <Cowboy@discussions.microsoft.com> a écrit dans le message de
news:B87FE184-6BF5-4881-A923-B2C91F8BDEEB@microsoft.com...
> VFP80 SP1 on XP
> I have a basegrid in MyClass.
> I have added it to a form. When I run the form, I programmatically want
to add a column and a Click() event to that column. I do not understand the
Help screens on this issue. Anyone have a simple example.
>
> TIA
>



Re: Adding events by Sietse

Sietse
Sat Jul 31 14:26:47 CDT 2004

Hi Cowboy,
You can get to what you want on two different manners:
1: Create a baseHeader and baseColumn class (programmatically) using DEFINE
CLASS, and set the memberclass property of the baseGrid to point to the
baseColumn and the memberclass property of the baseColumn to point to the
BaseHeader.
Now you can add columns of the class baseColumn just by setting the
columncount-property of the grid. You're free to place any custom code in
the baseColumn and baseHeader classses....

2: Use BINDEVENTS() to couple events of the column to a custom method you
define in the basegrid class.
F.I.
PROCEDURE ColumnClick()
AEVENTS(aEvnt,0)
oColumn = aEvnt[1] && Retrieve the object the event was triggered on....
MESSAGEBOX("Column Clicked...: "+ oColumn.Name)
ENDPROC

To bind the method to the column:
BINDEVENTS(loColumn, "Click", oGrid, "ColumnClick")

Best way is to place code in the grid, placing event-binding to all of its
columns:
BTW, The click event is absorbed by the top-level objects in the grid, being
the header-objects or the controls in the column. That's why the following
code binds all control's click-event to the ColumnClick method.
FOR EACH loColumn IN this.Columns
FOR EACH loControl IN loColumn.Objects
IF PEMSTATUS(loControl, "Click", 5)
BINDEVENTS(loControl, "Click", this, "ColumnClick")
ENDIF
NEXT
NEXT

HTH,
Sietse Wijnker.


"Cowboy" <Cowboy@discussions.microsoft.com> wrote in message
news:B87FE184-6BF5-4881-A923-B2C91F8BDEEB@microsoft.com...
> VFP80 SP1 on XP
> I have a basegrid in MyClass.
> I have added it to a form. When I run the form, I programmatically want
to add a column and a Click() event to that column. I do not understand the
Help screens on this issue. Anyone have a simple example.
>
> TIA
>