Category / Section
How to achieve Column wrapping in the WinForms GridControl?
1 min read
WrapText
The Column wrapping is achieved by using the WrapText property. It is used to apply the wrap text style to the particular cell, column or rows.
By using the GridModel
C#
this.gridControl1[0, 2].CellValue = "Wrap"; this.gridControl1.ColStyles[2].CellValue = " Wrapped text is shown"; // apply wrap text for the column this.gridControl1.ColStyles[2].WrapText = true;
VB
this.gridControl1[0, 2].CellValue = "Wrap"; Me.gridControl1.ColStyles(2).CellValue = "Wrapped text is shown" ' apply wrap text for the column Me.gridControl1.ColStyles(2).WrapText = True
By using the QueryCellInfo event
C#
void gridControl1_QueryCellInfo(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e) { if (e.ColIndex == 2 && e.RowIndex>0) { // apply wrap text for the column e.Style.WrapText = true; e.Style.CellValue = "Wrapped Text is Shown"; } }
VB
Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs) If e.ColIndex = 2 AndAlso e.RowIndex > 0 Then ' apply wrap text for the column e.Style.WrapText = True e.Style.CellValue = "Wrapped Text is Shown" End If End Sub
Note:
By default, the WrapText is set to true for all the columns.
The following screenshot displays the Column wrapping in GridControl.
Samples:
C#: ColumnWrapping
VB: ColumnWrapping