> 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;
}
}