Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid column CommandButton
Message
De
01/01/2020 18:37:17
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01672489
Message ID:
01672502
Vues:
62
Dmitry, you'll have to double check. It should be really straightforward.

A quick demo just to select and execute selection:
CREATE CURSOR DemoCursor (Id Int AUTOINC, Person Varchar(100))
INSERT INTO DemoCursor (Person) VALUES ("Joseph")
INSERT INTO DemoCursor (Person) VALUES ("Mary")
GO TOP

LOCAL DemoForm AS CommandInGrid

m.DemoForm = CREATEOBJECT("CommandInGrid")
m.DemoForm.Show(1)

DEFINE CLASS CommandInGrid AS Form

	ADD OBJECT MyGrid AS Grid

	PROCEDURE MyGrid.Init

		This.ColumnCount = 2

		WITH This.Columns(2)

			.Sparse = .F.

			.RemoveObject("Text1")
			.AddObject("MyCommand", "MyCommand")
			.MyCommand.Visible = .T.
			.CurrentControl = "MyCommand"

		ENDWITH

	ENDPROC

ENDDEFINE

DEFINE CLASS MyCommand AS CommandButton

	Caption = "Click me!"

	PROCEDURE Click
		MESSAGEBOX(TEXTMERGE("Ouch! <<DemoCursor.Person>>!"))
	ENDPROC

ENDDEFINE
>Antonio,
>
>Thank you for your suggestion. If I follow it, I still get the error:
>"CurrentControl : Expression evaluated to an illegal value"
>
>>Dmitry,
>>
>>You set the .CurrentControl, which is a string property, to the name you gave to the control (that would be "MyCommand").
>>
>>Since you're adding the object, you also must set its visibility to .T. for it to be shown and operational.
>>
>>That is:
>>
>>
>>with toGrid.columns(nColumn)
>>		.RemoveObject( "Text1" )	
>>		.AddObject( "MyCommand", "MyCommand" )
>>		.MyCommand.Visible = .T.
>>		.CurrentControl = "MyCommand"
>>endwith
>>
>>
>>>I still don't get it how to set the value of the CurrentControl in code.
>>>
>>>Here is the segment of my code that programatically changes the Text1 control to a button:
>>>
>>>with toGrid.columns(nColumn)
>>>		.RemoveObject( "Text1" )	
>>>		.AddObject( "MyCommand", "MyCommand" )	
>>>
>>>               **!! ERROR!
>>>		.CurrentControl = "cmdButton" && or "CommandButton" or "MyCommand"	
>>>
>>>
>>>What is wrong with the above code?
----------------------------------
António Tavares Lopes
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform