>loForm = createobject('myForm') >loForm.show(1) > >define class myForm as form > > > datasession = 2 > top = 0 > left = 0 > height = 357 > width = 615 > docreate = .t. > caption = "Form" > name = "myForm" > > > add object myGrid as grid with ; > columncount = 2, ; > anchor = 15, ; > height = 324, ; > left = 12, ; > panel = 1, ; > recordsource = "C_Test", ; > rowheight = 25, ; > top = 24, ; > width = 570, ; > themes = .f., ; > name = "myGrid" > > function setGridButtonCaption() > with thisform.myGrid.column2.myCommand > .caption = alltrim(c_test.somevalue) > endwith > return .f. > endfunc > > procedure GridButtonClicked() > messagebox('button ' + transform(c_test.pk) + ' clicked! (' + alltrim(c_test.somevalue) + ')') > endproc > > procedure init > with thisform.myGrid.Column1 > .controlsource = "C_Test.pk" > .name = "Column1" > endwith > > with thisform.myGrid.column2 > .controlsource = "c_test.somevalue" > .width = 100 > .sparse = .f. > .dynamicfontstrikethru = "thisform.setGridButtonCaption()" > .name = "Column2" > endwith > > with thisform.myGrid.Column1.header1 as header > .alignment = 2 > .caption = "PK" > .name = "Header1" > endwith > > with thisform.myGrid.Column1.text1 as textbox > .borderstyle = 0 > .margin = 0 > .forecolor = rgb(0,0,0) > .backcolor = rgb(255,255,255) > .name = "Text1" > endwith > > with thisform.myGrid.column2.header1 as header > .caption = "Your Command" > .name = "Header1" > endwith > > thisform.myGrid.column2.addobject('myCommand', 'commandbutton') > thisform.myGrid.column2.removeobject('text1') > > with thisform.myGrid.column2.myCommand as commandbutton > .caption = '' > .enabled = .t. > .visible = .t. > endwith > > thisform.myGrid.column2.CurrentControl = 'myCommand' > > BindEvent(thisform.myGrid.Column2.myCommand, 'Click', thisform, 'GridButtonClicked') > endproc > > procedure load() > create cursor C_Values (value C(15)) > create cursor c_test (pk int autoinc, somevalue C(10)) > > insert into C_Values (value) values ('Possible') > insert into C_Values (value) values ('Impossible') > insert into C_Values (value) values ('Probable') > insert into C_Values (value) values ('Improbable') > insert into C_Values (value) values ('Random') > > rand(-1) > do while reccount('C_Test') < 1000 > go (rand() * reccount('C_Values') + 1) in C_Values > insert into c_test (somevalue) values (C_Values.value) > enddo > go top in c_test > endproc > >enddefine >