Articles in this section
Category / Section

How to enable header cell borders if its celltype is set to TextBox in WinForm GridControl?

1 min read

By default, if the header cell type is set to TextBox, the cell borders of those cells will disappear. To draw the borders for the header cells, use the e.Style.Borders property of the QueryCellInfo event.

//Event Triggering.
this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo;
 
//Event Handling.
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if (e.ColIndex == 0)
    {
        e.Style.CellType = GridCellTypeName.TextBox;
        e.Style.Borders.Bottom = e.Style.Borders.Right = new GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 100, 100), GridBorderWeight.Thin);
        e.Style.Borders.Top = e.Style.Borders.Left = new GridBorder(GridBorderStyle.Solid, Color.White, GridBorderWeight.Thin);
    }
}
'Event Triggering.
AddHandler Me.gridControl1.QueryCellInfo, AddressOf gridControl1_QueryCellInfo
 
'Event Handling.
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
 If e.ColIndex = 0 Then
  e.Style.CellType = GridCellTypeName.TextBox
  e.Style.Borders.Right = New GridBorder(GridBorderStyle.Solid, Color.FromArgb(100, 100, 100), GridBorderWeight.Thin)
  e.Style.Borders.Bottom = e.Style.Borders.Right
  e.Style.Borders.Left = New GridBorder(GridBorderStyle.Solid, Color.White, GridBorderWeight.Thin)
  e.Style.Borders.Top = e.Style.Borders.Left
 End If
End Sub

The screenshots below illustrate the borders for the GridCells.


Showing disabled header cell border in WinForms Grid


Showing enabled header cell border in WinForms Grid


Sample Links:

C#: Cell border for TextBox celltype_CS

VB: Cell border for TextBox celltype_VB

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied