# Print

## Content

You can create a custom print preview and customize how your grid will appear when printed. You can do this using the [Init](/componentone/docs/win/online-truedbgrid/) method. To override properties like **FormBorderStyle**, **MaximizeBox**, **MinimizeBox**, **ControlBox** and so on of a Form inherited from C1.Win.C1TrueDBGrid.PrintForm, override the **Init** method of the **PrintForm**. First call the base.Init(), then set the properties you want.

Complete the following steps:

1. Navigate to the Toolbox and double-click the **SplitContainer** panel to add it to the Form.
2. Navigate to the Properties window and set the **SplitContainer** panel's **Orientation** property to **Horizontal**.
3. Click in the top panel of the **SplitContainer**, navigate to the Toolbox and double-click the **Button** control to add it to the application.
4. In the Properties window, set the **Button** control's **Text** property to "Preview".
5. Click in the bottom panel of the C1SplitContainer, navigate to the Toolbox, and locate and then double-click the **C1TrueDBGrid** control to add it to the application.
6. Click the **C1TrueDBGrid** control's smart tag and choose the **Dock in Parent Container** option from the **Tasks** menu.
7. Right-click the project in the Solution Explorer and select **Add Reference**. In the **Add Reference** dialog box, locate and select the **C1.Win.RibbonPreview.4.5.2** and **C1.Win.Ribbon.4.5.2** assemblies and click **OK**. This is required for enabling print preview.

>type=note
> **Note**: **TrueDBGrid**'s export and printing features uses the [C1.Win.Printing NuGet package](https://developer.mescius.com/componentone/docs/win/online-printdocument/overview), which provides three libraries: C1.PrintDocument, C1.Win.PrintPreview and C1.Win.RibbonPreview. Each library provides a set of previewing controls or components. The **PrintDocument** library provides the PrintDocument and MultiDocument components, the **PrintPreview** library provides the PreviewOutlineView, PreviewPane, PreviewTextSearchPanel, Thumbnail, PrintPreviewControl and PrintPreviewDialog components, and **RibbonPreview** provides the RibbonPreview and RibbonPreviewDialog components. Since C1Report is now obsolete, make sure that the references for C1Report libraries is replaced by individual library references in the C1.Win.Printing nuget.

8. In the Solution Explorer, right-click the project and select **Add \| Windows Form**. In the **Add New Item** dialog box, name the form "PrintForm1" and click the **Add** button.
9. Double-click the new form to switch to Code view.
10. Edit the initial class declaration to inherit from C1.Win.C1TrueDBGrid.PrintForm:

```csharp
public partial class PrintForm1 : C1.Win.C1TrueDBGrid.PrintForm
```

11. Add the following code below the class declaration:

```csharp
protected override void Init()
{
    base.Init();
    FormBorderStyle = FormBorderStyle.Sizable;
    this.ControlBox = true;
    this.MinimizeBox = false;
    this.MaximizeBox = false;
}
```

12. Return to **Form1** in Design view and double-click the **Button** to switch to Code view and create the **Button\_Click** event handler.
13. Add the following code to the **Button\_Click** event handler, making sure to replace "ProjectName" with the name of your project:

```csharp
c1TrueDBGrid1.PrintInfo.PreviewFormClassName = "ProjectName.PrintForm1";
c1TrueDBGrid1.PrintInfo.PrintPreview();
```

Run the application and notice the application appears with a button and grid displaying data. Click the Preview button and observe that a customized print preview form appears. The form only includes the **Close** button and not the **Minimize** and **Maximize** buttons.

![](https://cdn.mescius.io/document-site-files/images/a1b176e5-6638-4b1f-a786-e41a817558bb/images/printform.gif)