The simplest solution is to use an HBox, with horizontalAlign="center", then put the button inside that.
But using containers in renderers can cause performance problems if you have many renderers. See Alex's blog for examples on how to write lightweight renders. Tracy ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Mark Shen Sent: Thursday, April 24, 2008 3:25 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Button in DatGrid problem Please give me a simple demo, what "another layer" means? Thanks Mark ----- Original Message ---- From: Alex Harui <[EMAIL PROTECTED]> To: flexcoders@yahoogroups.com Sent: Thursday, April 24, 2008 3:04:24 PM Subject: RE: [flexcoders] Button in DatGrid problem A renderer is always as wide as its column. You can wrap it in another layer if you want to center it. ________________________________ From: [EMAIL PROTECTED] ups.com [mailto:flexcoders@ yahoogroups. com] On Behalf Of markflex2007 Sent: Thursday, April 24, 2008 11:05 AM To: [EMAIL PROTECTED] ups.com Subject: [flexcoders] Button in DatGrid problem Hi, I add a buttin in datagrid.But why the button always fill the all column width. I try to set it 20 but the column width is 100. it always like 100 in the layout. why? Thanks Mark <mx:DataGrid id="dg1" dataProvider ="{dp}"> <mx:columns> <mx:DataGridColumn width="100" headerText=" " > <mx:itemRenderer> <mx:Component> <mx:Button label="Select it" width="20" /> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn > <mx:DataGridColumn headerText=" names" dataField="names" width="200" /> <mx:DataGridColumn headerText=" sex" dataField="sex" width="300" /> </mx:columns> </mx:DataGrid> ________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. <http://us.rd.yahoo.com/evt=51733/*http:/mobile.yahoo.com/;_ylt=Ahu06i62 sR8HDtDypao8Wcj9tAcJ%20>