>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
>
Hi Mo,
If you show the related table info in the same grid, say, Status Description field instead of Numeric status using relation, here is the trick I used in the past.
In the table that described status I had an extra field (integer) for ForeColor (you can have it also for the backcolor).
Then I used this field in DynamicForeColor expression. The idea worked very fast.
Let me try to find the threads on this approach.
>
>>>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
>>
If it's not broken, fix it until it is.
My Blog