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 07:21 PM UTC

> 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 Syncfusion Team May 5, 2003 10:09 AM UTC

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

Loader.
Up arrow icon