ComponentOne True DBGrid for WinForms
How to Use Styles / Working with Style Properties / Anonymous Style Inheritance / Example 9 of 10: Setting the Alignment of C1DisplayColumn Objects
In This Topic
    Example 9 of 10: Setting the Alignment of C1DisplayColumn Objects
    In This Topic

    Setting the HorizontalAlignment property of a C1DisplayColumn object affects not only its data cells, but also its header and footer. The reason for this is that the default setting of the HorizontalAlignment property for the built-in Heading and Footing styles, which is inherited from the Normal style, is set to AlignHorzEnum.General. For data cells, the general setting means that the underlying data type determines whether the cell text is left, center, or right aligned; for column headers and footers, the general setting means that the column's data cell alignment should be followed.


    The following code sets the alignment of C1DisplayColumn objects:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Me.C1TrueDBGrid1.Splits(0).DisplayColumns(0).Style.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Center
    

    To write code in C#

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