# Print

FlexGrid for WinForms lets you print the grid and perform various basic and advanced print settings. Learn more about printing the grid here.

## Content

FlexGrid lets you print the grid and perform various basic and advanced print settings using its built-in methods and properties.

![Print grid](https://cdn.mescius.io/document-site-files/images/2f10b028-0ae8-4c29-a102-4d67578c339b/images/grid-print-preview.png)

## Print Grid

FlexGrid provides **PrintGrid** method of the **C1FlexGrid** class which lets you print the grid contents with some basic printing options. The method has an optional parameter **PrintGridFlags** that allows you to specify how to print the grid such as its scaling mode and whether to display various print related dialog boxes. You can also set text in header and footer of the printed grid using this method.

Following code shows how to use PrintGrid method to print the WinForms FlexGrid.

```csharp
// Display a preview dialog and print the grid with specified header and footer 
c1FlexGrid1.PrintGrid("C1FlexGrid", PrintGridFlags.FitToPageWidth | PrintGridFlags.ShowPreviewDialog, "C1FlexGrid\t\t" + String.Format(DateTime.Now.ToString(), "d"), "\t\tPage {0} of {1}");             
```

```vbnet
' Display a preview dialog and print the grid with specified header and footer 
c1FlexGrid1.PrintGrid("C1FlexGrid", PrintGridFlags.FitToPageWidth Or PrintGridFlags.ShowPreviewDialog, "C1FlexGrid" & vbTab & vbTab & String.Format(Date.Now.ToString(), "d"), vbTab & vbTab & "Page {0} of {1}")      
```

## Print Options

To set advanced printing options such as header and footer fonts, page margins, and page orientation, you can use **PrintParameter** property of the **C1FlexGrid** class.

Use the code below to print the WinForms FlexGrid with advanced print options.

```csharp
// Get the grid' s PrintDocument object.
System.Drawing.Printing.PrintDocument pd = c1FlexGrid1.PrintParameters.PrintDocument;
// Set up the page (landscape, 1.5" left margin).
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.Margins.Left = 150;
// Set up the header and footer fonts.
c1FlexGrid1.PrintParameters.HeaderFont = new Font("Arial Black", 14, FontStyle.Bold);
c1FlexGrid1.PrintParameters.FooterFont = new Font("Arial Narrow", 8, FontStyle.Italic);             
```

```vbnet
' Get the grid' s PrintDocument object.
Dim pd As Drawing.Printing.PrintDocument = c1FlexGrid1.PrintParameters.PrintDocument
' Set up the page (landscape, 1.5" left margin).
pd.DefaultPageSettings.Landscape = True
pd.DefaultPageSettings.Margins.Left = 150
' Set up the header and footer fonts.
c1FlexGrid1.PrintParameters.HeaderFont = New Font("Arial Black", 14, FontStyle.Bold)
c1FlexGrid1.PrintParameters.FooterFont = New Font("Arial Narrow", 8, FontStyle.Italic)         
```

## Customize Print Preview Dialog

You can customize the print preview dialog by using **PrintPreviewDialog** property of the **GridPrinter** class. The property can be accessed through **PrintParameter** property of the **C1FlexGrid** class. The code below uses the PrintPreviewDialog property to display a maximized preview dialog with a custom caption.

Below code demonstrates how to customize the print preview dialog of the WinForms FlexGrid.

```csharp
Form dlg = c1FlexGrid1.PrintParameters.PrintPreviewDialog as Form;
dlg.Text = "Order Details";
dlg.StartPosition = FormStartPosition.CenterParent;
dlg.WindowState = FormWindowState.Maximized;
c1FlexGrid1.PrintGrid("Orders", PrintGridFlags.ShowPreviewDialog);                 
```

```vbnet
Dim dlg As Form = TryCast(c1FlexGrid1.PrintParameters.PrintPreviewDialog, Form)
dlg.Text = "Order Details"
dlg.StartPosition = FormStartPosition.CenterParent
dlg.WindowState = FormWindowState.Maximized
c1FlexGrid1.PrintGrid("Orders", PrintGridFlags.ShowPreviewDialog)
```

## See Also

**Documentation**

[Print](/componentone/docs/win/online-flexgrid/features/save-load-print/print)