Category / Section
How to hide some columns and rows while printing in WinForms GridControl?
1 min read
Hide some columns and rows
When you want to hide some columns and rows while printing, you can do so by handling the QueryColWidth and QueryRowHeight events and when the grid is in the PrintingMode, set the size property to zero by checking its index. The following code example show its implementation.
C#
private void gridControl1_QueryRowHeight(object sender, Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs e) { if(this.gridControl1.PrintingMode) { if(e.Index == 2 || e.Index == 3) { e.Size = 0; e.Handled = true; } } }
VB
Private Sub gridControl1_QueryRowHeight(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridRowColSizeEventArgs) Handles gridControl1.QueryRowHeight If Me.gridControl1.PrintingMode Then If e.Index = 2 OrElse e.Index = 3 Then e.Size = 0 e.Handled = True End If End If End Sub
Reference link: https://help.syncfusion.com/windowsforms/grid-control/printing#printing-customizations