Thank a lot Adam! Works great!! --- In flexcoders@yahoogroups.com, "Adam Royle" <[EMAIL PROTECTED]> wrote: > > This works for me: > > private function selectAll():void > { > var a:Array = [], i:Number; > var num:Number = myDataProvider.length; > for (i=0;i<num;i++) a[i] = i; > myDataGrid.selectedIndices = a; > } > > > Cheers, > Adam > > > ----- Original Message ----- > From: ad9798 > To: flexcoders@yahoogroups.com > Sent: Sunday, February 11, 2007 11:14 AM > Subject: [flexcoders] Highlight and select all rows in datagrid by button. > > > I was able to select one row by doing > > myDataGrid.selectedIndex = 1; <== index number of the row. > > However, I'm trying to create a button that select all rows in datagrid. > I have tried following but no success.. > > private function selectAll() : void { > for( var i:int = 0; i < myDataProvider.length; i++ ){ > myDataGrid.selectedIndices[i] = i; > myDataGrid.selectedItems[i] = myDataProvider[i]; > } > } > > Any idea? any suggestion? >