Articles in this section
Category / Section

How to display "..." in a cell when the whole text is not wide enough in WinForms GridControl?

1 min read

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 WinForms GridControl to set the trimming for an entire column, use the following code example.

 

Using GridModel

// 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;
'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

//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;
    }
}
'Hook the event to set the trimming style to the column
AddHandler Me.gridControl1.QueryCellInfo, AddressOf 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

Conclusion

I hope you enjoyed learning about how to display "..." in a cell while the whole text is not wide enough in WinForms GridControl.

You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.

 

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

 

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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