ComponentOne True DBGrid for WinForms
Example 10 of 10: Setting the Alignment for Column Headers
How to Use Styles > Working with Style Properties > Anonymous Style Inheritance > Example 10 of 10: Setting the Alignment for Column Headers

This example illustrates the distinction between general and specific alignment for column headers and footers. If the HorizontalAlignment member of the HeadingStyle (or FooterStyle) property is not set to AlignHorzEnum.General, then the header (or footer) is aligned independently of the data cells.


The following code sets the alignment for column headers:

To write code in Visual Basic

Visual Basic
Copy Code
With Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0)
    .HeadingStyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Near
    .FooterStyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Far
    .Style.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Center
End With

To write code in C#

C#
Copy Code
this.c1TrueDBGrid1.Splits[0].DisplayColumns[0].HeadingStyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Near;
this.c1TrueDBGrid1.Splits[0].DisplayColumns[0].FooterStyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Far;
this.c1TrueDBGrid1.Splits[0].DisplayColumns[0].Style.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Center;
See Also