Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Control a row in a grid based on other row
Message
From
12/05/2008 16:13:15
 
 
To
12/05/2008 15:15:50
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01316474
Message ID:
01316502
Views:
20
>Can I control a row in a grid based on selection on other row in the grid.
>
>for example, I have data in a grid row (table column) that points to another row in the grid and I wish to do something with this row (disable, change color) based on data in other row (flag =true)
>
>is that possible? is there a setall() magic in the grid to accomplish this?

To expand on Naomi's reply - one way might be to store yourGrid.Recordsource's current key value in some property in yourGrid.AfterRowColChange(), and then evaluate that property in an expression stored in a yourGrid.Dynamic* property.

The example.prg below is an older one, does it do what you want?


hth
-Stefan
LOCAL oForm as Form
oForm = CREATEOBJECT('TestForm')
oForm.Show(1)
RETURN

DEFINE CLASS TestForm as Form
	CurrentValue = 0
	AutoCenter = .T.
	PROCEDURE Load
		CREATE CURSOR temp (test Int)
		LOCAL i
		FOR i = 1 TO 5
			INSERT INTO temp VALUES (1)
			INSERT INTO temp VALUES (2)
			INSERT INTO temp VALUES (3)
		ENDFOR
		GO TOP
	ENDPROC

	ADD OBJECT grdTest as Grid WITH ;
		Left = 10, Top = 10, ;
		Width = 350, Height = 220, ;
		Anchor = 15, ;
		RowSource = 'temp', ;
		ColumnCount = 1
	PROCEDURE grdTest.Init
		This.SetAll('DynamicForeColor','This.DynamicX()','Column')
	ENDPROC
	PROCEDURE grdTest.DynamicX
		LOCAL lnColor
		lnColor = RGB(0,0,0)
		IF temp.test = Thisform.CurrentValue
			lnColor = RGB(255,0,0)
		ENDIF
		RETURN m.lnColor
	ENDPROC
	PROCEDURE grdTest.AfterRowColChange(nColIndex)
		Thisform.CurrentValue = temp.test
		This.Refresh()
	ENDPROC
ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform