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

Header alignment

How would you set column header alignment automatically in a GridDataBoundGrid. I want the header alignment to be the same as the column alignment. I've tried doing this in PrepareViewInfo, but it doesn't seem to work. The only way I can see to do this is to create a new HeaderBaseStyle, but I'm looking for a more "automated" way of doing this. Thanks Jeremy

2 Replies

AD Administrator Syncfusion Team May 4, 2003 03:21 PM

> How would you set column header alignment automatically in a GridDataBoundGrid. > > I want the header alignment to be the same as the column alignment. > > I've tried doing this in PrepareViewInfo, but it doesn't seem to work. > > The only way I can see to do this is to create a new HeaderBaseStyle, but I'm looking for a more "automated" way of doing this. > > Thanks > Jeremy > > > Did you use the HorizontalAlignment property? This seems to work for me.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex > 0 && e.RowIndex == 0)
	{
		int field = this.gridDataBoundGrid1.Binder.ColIndexToField(e.ColIndex);
		e.Style.HorizontalAlignment = this.gridDataBoundGrid1.Binder.InternalColumns[field].StyleInfo.HorizontalAlignment;
	}
}


UN Unknown May 5, 2003 06:09 AM

Clay Sorry - I was being dopey - I had previously jumped out of PrepareViewInfo if e.rowindex=0 Thanks Jeremy

Loader.
Live Chat Icon For mobile
Up arrow icon