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
>