)
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 "..." in a cell while the whole text is not enough wide in WinForms GridControl, GridGroupingControl and GridDataBoundGrid?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: February 10, 2015 |
Last Revised Date: February 11, 2020
Tags: styling

Trimming text

You can show the cell’s content like “…” at the end while it’s not enough to display the whole text, by setting the GridStyleInfo's Trimming property. In a GridControl to set the trimming for an entire column, use the following code example.

Using GridModel

C#

// GridControl
this.gridControl1.ColStyles[2].Trimming = StringTrimming.EllipsisWord;
// GridGroupingControl
this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.WrapText = false;
this.gridGroupingControl1.TableDescriptor.Columns["ColumnName"].Appearance.AnyRecordFieldCell.Trimming = StringTrimming.EllipsisWord;
// GridDataBoundGrid
this.gridDataBoundGrid1.Binder.InternalColumns["ColumnName"].StyleInfo.Trimming = StringTrimming.EllipsisWord;

VB

' GridControl 
Me.gridControl1.ColStyles(2).Trimming = StringTrimming.EllipsisWord
' GridGroupingControl 
Me.gridGroupingControl1.TableDescriptor.Columns("ColumnName").Appearance.AnyRecordFieldCell.WrapText = False
Me.gridGroupingControl1.TableDescriptor.Columns("ColumnName").Appearance.AnyRecordFieldCell.Trimming = StringTrimming.EllipsisWord
' GridDataBoundGrid  
Me.gridDataBoundGrid1.Binder.InternalColumns("ColumnName").StyleInfo.Trimming = StringTrimming.EllipsisWord

Using QueryCellInfo

C#

//Hook the event to set the trimming style to the column
this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo;
void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if(e.ColIndex == 2)
    {
          //Apply trimming for the column
          e.Style.Trimming = StringTrimming.EllipsisWord;
    }
}

VB

'Hook the event to set the trimming style to the column
Me.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
    If e.ColIndex = 2 Then
          'Apply trimming for the column
          e.Style.Trimming = StringTrimming.EllipsisWord
    End If
End Sub

The following screenshot illustrates the output.

GridControl with ellipsis word trimming

Figure 1: GridControl with EllipsisWord Trimming

Samples:

C#: GridCellTrimm

VB: GridCellTrimm

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