$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
DataGridView WinForms Control
Print grid by using the GridView .NET component in C# Windows Forms application.
Home > WinForms UI Controls > User Manual > Grid Print Style in C#

Grid Printing Style using GridView

DataGridView .NET Component for Windows Forms provides various settings to customize the grid print style with GridView in C#.NET. The GridView supports native print and the users of the application can directly pass the content of grid to a printer. By using the GridView .NET WinForms Control with friendly user dialogs, the UI designers can easily change the print settings, set watermark to the content of the grid and preview the print gird.

Properties for Customizing Grid Print Style

To create custom grid printing style, the users need to use the PrintStyle property included in the GridView control. The customization can be accomplished by either setting this property to a new instance of the GridPrintStyle C# class or editing the current one. The following are the properties used for customizing the grid printing.
  • PrintGrouping, this property is used to determine whether the GridView will print the grid grouping or not.
  • PrintSummaries, this property is used to determine whether the GridView will print summary rows or not.
  • PrintHiddenRows, this property is able to control whether the GridView will print hidden rows or not.
  • PrintHiddenColumns, this property is able to determine whether the GridView will print hidden columns or not
  • PrintHeaderOnEachPage, this property is used to control whether the GridView will print the header cells on each page or not.
  • FitWidthMode, this property is used to determine how to place the Kettic GridView on the page. The valid settings of the property include: NoFit used to align the grid to the left and will not change the grid size, NoFitCentered used to center the grid and will not change the grid size, and FitPageWidth used to resize the grid based on the column ratios to fill the entire page.
  • GridFont, this property allows the users customize the header cells font, data cells font, group cells font and summary cells font.

C# code for Customizing GridPrintStyle

The following is the C# code which uses the properties above to customize the grid print style.

GridPrintStyle style = new GridPrintStyle();
style.FitWidthMode = PrintFitWidthMode.FitPageWidth;
style.PrintGrouping = true;
style.PrintSummaries = false;
style.PrintHeaderOnEachPage = true;
style.PrintHiddenColumns = false;

this.ketticGridView1.PrintStyle = style;

Print Multiple Pages of Grid in C#.NET Projects

Kettic GridView C#.NET WinForms control is capable of printing multiple pages for gird. This feature is done by setting the ViewDefinition to TableViewDefinition and is enabled by defining the collection of columns all pages will contain. Here we need to use the PrintPages collection of the TableViewDefinitionPrintRenderer and the PrintPages collection includes collection of columns, each of which stands for a separate page.
The C# code below demonstrates how to print multiple pages.

GridPrintStyle printStyle = new GridPrintStyle(this.ketticGridView1);
TableViewDefinitionPrintRenderer renderer = new TableViewDefinitionPrintRenderer(this.ketticGridView1);
renderer.PrintPages.Add(this.ketticGridView1.Columns[0], this.ketticGridView1.Columns[2], this.ketticGridView1.Columns[5]);
renderer.PrintPages.Add(this.ketticGridView1.Columns[0], this.ketticGridView1.Columns[1], this.ketticGridView1.Columns[9]);
renderer.PrintPages.Add(this.ketticGridView1.Columns[8], this.ketticGridView1.Columns[7]);
renderer.PrintPages.Add(this.ketticGridView1.Columns[3], this.ketticGridView1.Columns[4], this.ketticGridView1.Columns[6]);
printStyle.PrintRenderer = renderer;
this.ketticGridView1.PrintStyle = printStyle;
UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls