datagrid Header Center

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jose

    #1

    datagrid Header Center

    Please como center a datagrid header and the data justify to right?

    Thanks a lot


  • Marius Groenendijk

    #2
    Re: datagrid Header Center

    Jose,

    I use a *HACK* to do it in .NET V1.1

    Subclass DataGridColumnS tyle and then override its
    Alignment and Paint methods

    If it's painting a cell you should use the intended aligment.
    If it's *not* painting a cell, then it's supposedly painting
    the column header, then you should use Center aligment.

    <code>
    Public Overrides Property Alignment() As
    System.Windows. Forms.Horizonta lAlignment
    Get
    If _painting Then
    Return MyBase.Alignmen t ' = intended alignment
    Else
    'probly painting header?
    Return HorizontalAlign ment.Center
    End If
    End Get
    Set(ByVal value As System.Windows. Forms.Horizonta lAlignment)
    MyBase.Alignmen t = value
    End Set
    End Property

    Protected Overloads Overrides Sub Paint( ... )
    _painting = True
    MyBase.Paint( ... )
    _painting = False
    End Sub
    </code>

    HTH,
    Marius.

    "Jose" <josenospam@uni ca.com> wrote in message
    news:uPn6EoXiGH A.3884@TK2MSFTN GP04.phx.gbl...[color=blue]
    > Please como center a datagrid header and the data justify to right?
    >
    > Thanks a lot
    >[/color]


    Comment

    Working...