Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Command Button in Grid
Message
From
27/05/2004 11:21:06
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00907664
Message ID:
00907773
Views:
11
This message has been marked as a message which has helped to the initial question of the thread.

Hi all:

Using Visual FoxPro 7.0

I know that I can insert a command button into a grid column, but is there anyway to assign the current record field [ControlSource] to the button1.caption?

For example:

If I have three records in the grid:

MyCursor.field1
#123
#456
#678

I want the caption of the command button(s) in the grid to be:
#123
#456
#678

Thanks!

--Paul


Hi Paul.

Yes, but in order to make this you must have courage.

Run this example and uncomment the lines on the middle .
PUBLIC oform1

oform1=NEWOBJECT("form1")
oform1.Show
RETURN

DEFINE CLASS form1 AS form

	ADD OBJECT grid1 AS grid WITH ;
		ColumnCount = 1, ;
		Left = 33, ;
		Top = 29, ;
		Column1.Sparse = .F.

	PROCEDURE grid1.column1.Init
		this.RemoveObject('text1')
		STORE this.AddObject('cmd',"myCommandButton") TO this.cmd.Visible

* UNCOMMENT NEXT LINE AND FIELD VALUE IS SHOW
*		this.cmd._ControlSource = "myCursor.field1"
	ENDPROC

	PROCEDURE Load
		CREATE CURSOR myCursor ( field1 C(10))
		INSERT INTO myCursor VALUES ('#123')
		INSERT INTO myCursor VALUES ('#456')
		INSERT INTO myCursor VALUES ('#678')
		GO TOP 
	ENDPROC

ENDDEFINE

* IF YOU DO NOT CHANGE _ControlSource it operate like a standard commandButton

DEFINE CLASS myCommandButton AS CommandButton
	
	Caption = 'Command'
	
	_ControlSource = "m.This.Caption"

	HIDDEN PROCEDURE SpecialEffect_Access
		this.Caption = EVAL(m.this._Controlsource)
		RETURN m.This.SpecialEffect
	ENDPROC

ENDDEFINE
If you have a commandButton devBaseclass you can add this little changes to it.

Fabio
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform