Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Control a row in a grid based on other row
Message
 
 
To
13/05/2008 16:16:10
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:
01316797
Views:
12
OIC. I misunderstood, thinking it was a parent-child relationship in the grid, not in the table itself.

Understood perfectly about the boss. We have those, too <g>.

>Mike
>
>That was my first plan but the application has been in production for years. Introducing a new table will affect many screens and reports. My boss did not like the 2 grids approach, you know he signs the check.
>
>Mo
>
>>Maybe the problem will become simpler if you rethink the approach. Why do you have a parent-child relation in the same grid? You might instead use two grids. Or a grid for the child table and separate controls such as textboxes for the parent record?
>>
>>
>>>Stefan
>>>
>>>Your example answered my question but my problem is bit more complex. I have many parent-child relation in the same grid.
>>>
>>>So far, I don't think setall() going to work for this problem. Let me work on it some more and let you know what happened. I will put more details if still need help.
>>>
>>>Thanks
>>>
>>>
>>>>>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
Reply
Map
View

Click here to load this message in the networking platform