>>Form has parent and child grid controls, e.q. document and document rows.
>>When child grid is active, it is desirable that current row in parent
>>grid is distinguishable from others.
>>
>>I did the following things in parent grid control:
>>
>>1. added currec property
>>2. .dynamicbackcolor = IIF( recno()=this.currec, rgb(0,0,128), this.backcolor)
>>3. Afterrowcolchange event
>> this.currec = recno()
>>
>>4. Beforerowcolchange event
>> IF recno()!=this.currec
>> this.currec = 1
>> ENDIF
>>
>>However, this will not work properly: sometimes row is not highlighted at all, sometimes two rows are highlighted.
>>How to do it ?
>>Maybe it can be done when grid loses focus, but grid has not lostfocus event.
>
>Hi Andrus,
>Here is how I handle it. I have a grid class with a method markrow and property nCurrec holding current record. Grid's cN2RGB method returns any numeric color back to RGB format as a string (not needed in fact but I use it some extra grid props).
>
>
>* Grid.Afterrowcolchange event
>if recno(this.recordsource) # This.ncurrec
> this.nCurrec = recno()
> this.markrow()
>endif
>
>* grid.Markrow method
>thisform.lockscreen = .t.
> This.setall("dynamicbackcolor", ;
> "iif(recno(["+this.recordsource+"]) = "+transform(this.nCurRec,"99999")+;
> ",RGB(0,0,128),"+this.cN2RGB(this.backcolor) +")","column")
> thisform.refresh()
>thisform.lockscreen = .f.
>
>*Grid.cN2RGB
>lparameters nColor
>return "RGB("+ ;
> str(nColor%256,3)+","+;
> str(floor(nColor%256^2 / 256),3)+","+;
> str(floor(nColor / 256^2),3)+")"
>
>
>
>When you want this to work from outside of the grid (ie: del current rec through a button and mark next avaliable row) you could setfocus to grid with a var set to .t. and from grid if that var is .t. make it .f. and setfocus to caller. Here is in code :
>
>* Button.click
>Do whatever you do
>
>lJustmark = .t.
>oCaller = this
>thisform.mygrid.setfocus
>
>* Grid.Afterrowcolchange event
>..
>if lJustMark
> lJustMark = .f.
> oCaller.setfocus()
>endif
>
>
>Cetin
Pretty Nifty.
Bill
Bill Morris