Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid command button column
Message
From
24/12/2007 09:53:19
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
24/12/2007 07:06:22
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01277298
Message ID:
01277332
Views:
26
>Hi
>I know how to add command button manually to grid.
>But I prefer to build my grid in grid.init, something like this:
>with this
>	.columncount=2
>	.recordsource="crsr1"
>	.column1.controlsource="crsr1.id"
>	.column1.header1.caption='ID'
>
>	.column2.controlsource="crsr1.prudact"
>	.column2.header1.caption='Prudact'
>	.setall("width",111,"column")
>		.setall("alignment",2,"column")
>	.setall("alignment",2,"header")
>	.refresh
>endwith
>My quastion is how can I add (via nint) another column with command button and to manipulate the commandbutton.click code.

I'll repeat what Hilmar said - just a few more details. Class myCmdButt is defined somewhere - in a prg or in a vcx, your call. The .click() method is defined there (or you can bindevent() to it - and that was in VFP8, IIRC) You maybe don't need to remove the default textbox, but I've always found it easier to live without it.
.addobject("colWithButton","column")
with getpem(this, "colWithButton")
   .addobject("cmdButt", "myCmdButt")
   .currentcontrol="cmdbutt"
   .removeobject("text1")
   .sparse=.f.
   * any other properties you may want to set - header caption, alignment etc)
   *-- and bindevent, if you want to go that way
   bindevent(this.colwithbutton.cmdButt, "click", thisform, "DoGridButtonClick")
endwith
As for the bindevent() versus code in the button - since you are adding the button on the fly, you can't have the code in the instance, it must be elsewhere. To me, it's more OOP to do that in the class, i.e. have a special button class for this occasion, which will hold everything that pertains to that button. If it's just a generic button and the code it runs is specific to this form anyway - i.e. if the code would be the standard "thisform.doSomething()" line, then bindevent() looks cleaner.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform