list's have a selectedItem property that does the comparison for you to find the index and select it, so according to your description you could set grid.selectedItem = selectedItem(the var you're keeping)
On Thu, Jun 26, 2008 at 7:04 AM, bray_6 <[EMAIL PROTECTED]> wrote: > You can use arraycollection getItemIndex() to get the object's index > then use it for the datagrid's selectedIndex. > > HTH, > Bray > > > --- In [email protected] <flexcoders%40yahoogroups.com>, "fb6668" > <[EMAIL PROTECTED]> wrote: > > > > Hi. > > > > I have a datagrid component which has a dataProvider of an > > arraycollection of objects. > > > > I also have a variable "selectedItem", which holds an object that has > > been selected elsewhere in the application. > > > > What I need is, when I create my datagrid, to set the background > > colour of the row corresponding to this selectedItem object. > > > > So I guess I need to loop through the dg's rows, comparing the > > dataItem of the row to selectedItem. However, I don't know how to loop > > the rows in a DataGrid?? > > It's so easy in C#.NET, and not here, so I think I may be approaching > > this from the wrong angle. > > > > Any ideas? > > > > Thanks! > > > > >

