)
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 display the long text in header cells as viewable in WinForms GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: February 15, 2016 |
Last Revised Date: December 17, 2019

Display the column header text

By default, the cell value will be displayed as per the data that we provided to the grid. In this case, if the particular column has the data with minimum length i.e. 3 to 4 characters and header text as long, the column will be resized as per the header text length.

                          Display the long column header text

In order to display the column header text fully and resize the column based on the data, the Orientation property can be used to display the header text as vertically.

GridControl

C#

for (int j = 0; j < this.grid.ColCount; j++)
{
   style1 = grid[0, j];
   font = style1.Font;
   //Rotate the text of Column header using array values
   font.Orientation = 270; 
   style1.Text = "Angle" + j.ToString();
}

 

VB

For j As Integer = 0 To Me.grid.ColCount – 1
   style1 = grid(0, j)
   font = style1.Font
   'Rotate the text of Column header using array values
   font.Orientation = 270
   style1.Text = "Angle" & j.ToString()
Next j

 

GridGrouping Control

C#

private void btnchange_Click(object sender, EventArgs e)
{
   foreach (GridColumnDescriptor column in     this.gridGroupingControl1.TableDescriptor.Columns)
   {
      column.Appearance.ColumnHeaderCell.Font.Orientation = 270;   
   }
}

 

VB

Private Sub btnchange_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnchange.Click
   For Each column As GridColumnDescriptor In    Me.gridGroupingControl1.TableDescriptor.Columns
     column.Appearance.ColumnHeaderCell.Font.Orientation = 270
   Next column 
End Sub

 

Screenshot

CellGrid

Display the long column header text in cellgrid

DataGrid

Display the long column header text in datagrid

Samples:

C#: Header Alignment_CS

VB: Header Alignment_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