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
close icon

align text header of a column in grid control

hi to all, how can align the text header of a column to the left or to the right. by default all the columns are align center best regards and thanks in advance fady

5 Replies

AD Administrator Syncfusion Team April 20, 2006 11:26 AM UTC

Hi Fady, Please try this code //For Left this.gridDataBoundGrid1.BaseStylesMap["Column Header"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left; //For Right this.gridDataBoundGrid1.BaseStylesMap["Column Header"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Right; Let us know if this helps Regards, Haneef


FS Fady Sayegh April 20, 2006 11:48 AM UTC

Hi Haneef, thanks to your reply, but i''m working with GridControl and not GridDataBoundGrid. in GridControl i write these two lines gridControl1.ColCount = 2; gridControl1.BaseStylesMap[1].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left; and the second line gives me this error : System.NullReferenceException best regards and thanks in advance fady


AD Administrator Syncfusion Team April 20, 2006 12:10 PM UTC

Hi Fady, You need to use this code for GridControl.Here is a code snippet this.gridControl1.BaseStylesMap["Column Header"].StyleInfo.HorizontalAlignment = GridHorizontalAlignment.Left; Here is a sample. http://www.syncfusion.com/Support/user/uploads/gc123_988ec04f.zip Let us know if this helps. Regards, Haneef


FS Fady Sayegh April 20, 2006 12:22 PM UTC

Hi Haneef, thanks to your reply it works. the code you gave me align the header text of all columns. but can i align the header text of the first column to the left and align the header text of the second column to the right best regards and thanks in advance fady


AD Administrator Syncfusion Team April 20, 2006 12:45 PM UTC

Hi Fady, Try this code //For First Column this.gridControl1[0,1].HorizontalAlignment = GridHorizontalAlignment.Left; //For Second Column this.gridControl1[0,2].HorizontalAlignment = GridHorizontalAlignment.Right; Thanks for your interest in Syncfusion Products. Regards, Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon