)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set the coveredrange cell in the rowheader to any other format in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 20, 2019

Customize the rowheader border style

You can set the CoveredRange cell in the row header to any other format. You can set any shape to the row header by hiding the borders of the covered range cells. Actually, the headers do not have borders, but instead have a raised appearance that is part of their drawing code. So, to control the borders, change the CellType to something other than the header. Making the row header cell Static is one option. You can customize the cells styles by using the QueryCellInfo event.

C#

void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
   //Changes the Rowheader CellType and Bottom and right borders.
   if ((e.RowIndex == 0 && e.ColIndex > -1) || (e.RowIndex > 0 && (e.ColIndex == 0)))
   {
     e.Style.CellType = "Static";
     e.Style.Borders.Bottom = new GridBorder(GridBorderStyle.Solid, Color.Green, GridBorderWeight.Medium);
     e.Style.Borders.Right = new GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.ExtraThick);
    }
    //Hides bottoms cells border.
    if ((e.RowIndex >= 2 && e.RowIndex < 5) && e.ColIndex == 0)
    {
      e.Style.Borders.Bottom = GridBorder.Empty;
    }
    //Hide right...
    if (e.RowIndex == 2 && e.ColIndex == 0)
    {
       e.Style.Borders.Right = GridBorder.Empty;
    }
}

VB

Private Sub Model_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
    'Changes the Rowheader CellType and Bottom and right borders.
    If (e.RowIndex = 0 AndAlso e.ColIndex > -1) OrElse (e.RowIndex > 0 AndAlso (e.ColIndex = 0)) Then
 e.Style.CellType = "Static"
 e.Style.Borders.Bottom = New GridBorder(GridBorderStyle.Solid, Color.Green, GridBorderWeight.Medium)
 e.Style.Borders.Right = New GridBorder(GridBorderStyle.Dotted, Color.Red, GridBorderWeight.ExtraThick)
    End If
    'Hides bottoms cells border.
    If (e.RowIndex >= 2 AndAlso e.RowIndex < 5) AndAlso e.ColIndex = 0 Then
 e.Style.Borders.Bottom = GridBorder.Empty
    End If
    'Hides right2...
    If e.RowIndex = 2 AndAlso e.ColIndex = 0 Then
 e.Style.Borders.Right = GridBorder.Empty
    End If
End Sub

 

GridControl with customized rowheader border style

Samples:

C#: CustomRowHeader-C#

VB: CustomRowHeader-VB

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon