Also, you asked for "...do the same as if the user clicked on a row ..." Be aware that if you have a handler function on the "change" event, it will not be called when you programatically set selectedIndex. The event "valueCommit" does change when the index is set programatically. Watch out for null references in a handler on this event, because it is called by the framework, not just by your code.
Tracy ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: Tuesday, October 16, 2007 3:06 PM To: [email protected] Subject: RE: [flexcoders] Can the Datagrid do this ? You want to set selectedItem if you can get your hands on the exact item in the dataprovider. Otherwise, you have to scan for the item in order to figure out the index of it and set selectedIndex. If you have sorted your collection, you can use findAny on an IViewCursor, but that essentially does a scan too. Because there are different ways to scan, it is not a feature of the controls. ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Jeffry Houser Sent: Tuesday, October 16, 2007 10:32 AM To: [email protected] Subject: Re: [flexcoders] Can the Datagrid do this ? I think selectedIndex needs an integer. You'd have to loop over the data provider, figure out which one has capital==Paris' and then set the selectedIndex based on that. You could also experiment with selectedItem; although I haven't experimented with setting that. d coda wrote: > > > Hi all > > I need to programmatically select a particular row in a datagrid and > cannot see how it is done. I want to do the same as if the user > clicked on a row only programmatically. > > Say I had a DataGrid with ID=dg containing two columns Countries and > Capitals. > > I want to be able to issue a command like: > > dg.selectedIndex = dg.capitals=="Paris "; > > ie to select the row that contains Paris in the Capitals column. > > As if the user selected the France/Paris row only doing it programmatically. > > I am thinking it must be a feature but cannot find it :( > > Please shed some light or even let me know if what I want sounds crazy. > > -D > > -- Jeffry Houser, Technical Entrepreneur, Software Developer, Author, Recording Engineer AIM: Reboog711 | Phone: 1-203-379-0773 -- My Company: <http://www.dot-com-it.com <http://www.dot-com-it.com> > My Podcast: <http://www.theflexshow.com <http://www.theflexshow.com> > My Blog: <http://www.jeffryhouser.com <http://www.jeffryhouser.com> >

