We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Platform: WinForms |
Control: GridControl |
Published Date: April 30, 2011 |
Last Revised Date: December 20, 2019

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

Samples: http://help.syncfusion.com/support/samples/kb/Grid.Windows/PrintColRowHidden/Print_Cols_Rows_Hidden.zip

Reference link: https://help.syncfusion.com/windowsforms/grid-control/printing#printing-customizations

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon