Articles in this section
Category / Section

How to hide columns and rows while printing in WinForms GridControl?

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 shows its implementation.

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;
      }
   }
}
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: Printing

Conclusion

I hope you enjoyed learning about how to hide some columns and rows while printing 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)
Access denied
Access denied