How to achieve Column wrapping in the WinForms GridControl?
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
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
Conclusion
I hope you enjoyed learning about how to achieve Column
wrapping in the WinForms GridControl.
You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinForms GridControl example to understand how to create and manipulate data.
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!