We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to set column text alignment?

It seems to me that this line of code should change the way text is aligned in a grid: me.grid.ColStyles(1).TextAlign = GridTextAlign.Right but this doesn't appear to do anything. What does it do, and how can I change a column's text alignment if this doesn't work?

4 Replies

AD Administrator Syncfusion Team September 25, 2003 06:53 PM UTC

Don't confuse this with HorizontalAlignment. TextAlign specifies if text should be displayed left or right of any cell button elements. See HorizontalAlignment how to align text left, centered and right inside a cell rectangle. Stefan


JE Jeff May 23, 2004 02:16 PM UTC

Honestly, Um.. HorizontalAlignment only seems to be aligning text in headers? >Don''t confuse this with HorizontalAlignment. > >TextAlign specifies if text should be displayed left or right of any cell button elements. > >See HorizontalAlignment how to align text left, centered and right inside a cell rectangle. > >Stefan > >


AD Administrator Syncfusion Team May 23, 2004 04:20 PM UTC

Are you using a GridControl or a GridDataBoundGrid?


AD Administrator Syncfusion Team November 12, 2004 04:22 PM UTC

style.HorizontalAlignment is the property to use. We do not know of a problem like this. Take a look at the grid\sample\getting started\cellstyles sample. It shows this property in use. For a GridDataBoundGrid, you do have to set it on the whole column using either grid.GridBoundColumns["Col1"].StyleInfo or grid.Binder.InternalColumns[''Col1"].StyleInfo. But it should work. To set it cell by cell in a GridDataBoundGrid, you would use the PrepareViewStyleInfo event. Make sure you are not trying to set it on a style that has been set to ReadOnly without useing teh grid.IgnoreReadOnly property. If you can post a little sample project where it does not work, we can try to track down the problem.

Loader.
Live Chat Icon For mobile
Up arrow icon