DEFINE CLASS MyCommand AS Container BackStyle = 0 BorderWidth = 0 ADD OBJECT MyButton AS CommandButton WITH Caption = "Click me!" PROCEDURE MyButton.Click MESSAGEBOX(TEXTMERGE("Ouch! <<DemoCursor.Person>>!")) ENDPROC ENDDEFINE>Antonio,
>.CurrentControl = "MyCommand" >>the code works just as well. I probably didn't explain my issue correctly. I wanted the button to be narrower than the column width. And no matter what I do (specify width), the button extends to the width of the column.
>>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 >>>>
>>>>with toGrid.columns(nColumn) >>>> .RemoveObject( "Text1" ) >>>> .AddObject( "MyCommand", "MyCommand" ) >>>> .MyCommand.Visible = .T. >>>> .CurrentControl = "MyCommand" >>>>endwith >>>>>>>>
>>>>>with toGrid.columns(nColumn) >>>>> .RemoveObject( "Text1" ) >>>>> .AddObject( "MyCommand", "MyCommand" ) >>>>> >>>>> **!! ERROR! >>>>> .CurrentControl = "cmdButton" && or "CommandButton" or "MyCommand" >>>>>>>>>>