oForm=Createobject("myForm")
oForm.AddObject('myGrid1','myGrid')
oForm.myGrid1.column1.header1.Caption = "Name"
oForm.myGrid1.column2.header1.Caption = "Color"
oForm.myGrid1.column2.Sparse = .F.
oForm.myGrid1.column2.AddObject("TextRed1","TextRed")
oForm.myGrid1.column2.AddObject("TextBlue1","Textblue")
oForm.myGrid1.column2.AddObject("TextYellow1","TextYellow")
oForm.Show(1)
Define Class myForm As Form
AutoCenter = .T.
Procedure Load()
Create Cursor myCursor (Name C(20),Color C(10))
Insert Into myCursor (Name,Color) Values ("MIKE","BLUE")
Insert Into myCursor (Name,Color) Values ("JOHN","RED")
Insert Into myCursor (Name,Color) Values ("PAUL","YELLOW")
Go Top
Endproc
Enddefine
Define Class myGrid As Grid
Visible = .T.
ColumnCount = 2
Width = 200
Top = 20
Left = 20
Procedure Init()
With This
.column2.DynamicCurrentControl = "dynamic()"
This.Parent.LockScreen = .F.
Endwith
Endproc
Enddefine
Define Class TextRed As TextBox
BackColor = Rgb(255,0,0)
Visible = .T.
Procedure Click
This.Parent.Parent.Parent.LockScreen = .T.
This.Parent.Parent.Init()
Endproc
Enddefine
Define Class TextBlue As TextBox
BackColor = Rgb(0,128,255)
Visible = .T.
Procedure Click
This.Parent.Parent.Parent.LockScreen = .T.
This.Parent.Parent.Init()
Endproc
Enddefine
Define Class TextYellow As TextBox
BackColor = Rgb(255,255,0)
Visible = .T.
Procedure Click
This.Parent.Parent.Parent.LockScreen = .T.
This.Parent.Parent.Init()
Endproc
Enddefine
Function Dynamic
Do Case
Case myCursor.Color = "RED"
Return "textRed1"
Case myCursor.Color = "BLUE"
Return "textBlue1"
Case myCursor.Color = "YELLOW"
Return "textYellow1"
Endcase
Endfunc