Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use DynamicCurrentControl in a grid (programmaticaly)

Grids

How to use DynamicCurrentControl in a grid (programmaticaly)

by  Mike Gagnon  Posted    (Edited  )
Code:
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
Mike Gagnon
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top