---
title: "The PrintPreviewDialog and PrintDialog Control in C#.Net"  
description: "PrintDocument PrintPreviewDialog and PrintDialog Control in C#.NetWhere, The PrintDialogControls are used to open the Windows Print Dialog. The Prin"  
author: "Pushpendra Singh"  
published: 2011-01-25  
updated: 2020-05-30  
canonical: https://www.mindstick.com/articles/425/the-printpreviewdialog-and-printdialog-control-in-c-sharp-dot-net  
category: "c#"  
tags: ["c#", ".net", ".net framework"]  
reading_time: 2 minutes  

---

# The PrintPreviewDialog and PrintDialog Control in C#.Net

## PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net

Where, The PrintDialogControls are used to open the Windows Print Dialog. The PrintDocument component [allows users to send an](https://www.mindstick.com/Articles/416/richtextbox-control-in-c-sharp-dot-net) output to a printer. With the help of PrintPreviewDialog, You can preview a document.\

#### How to PrintDocument and check PrintPreview

Drag and drop PrintDocument control, PrintDialog [control and PrintPreview](https://www.mindstick.com/articles/853/writing-data-to-excel-sheet-using-c-sharp)Dialog control from the toolbox on the WindowForm.

![PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net](https://www.mindstick.com/mindstickarticle/0bbfc045-89ac-4885-915f-0f03157ec85f/images/d6b7310b-8894-4e57-95d9-571df82be42f.png)

![PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net](https://www.mindstick.com/mindstickarticle/0bbfc045-89ac-4885-915f-0f03157ec85f/images/6b2211c5-d8ad-4597-9ef3-b799157ffdb5.png)

**PrintDocument:** The PrintDocument object encapsulates all the information needed to print a page. They associate with the control which content can be print. They handle the events and operations of printing.

**Step1:** Associate control to Print document

```
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e){           e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 100, 20);           e.Graphics.PageUnit = GraphicsUnit.Inch;           }
```

**Step2:** write code for printing and print preview.

```
private void btnPrint_Click(object sender, EventArgs e){            //PrintDialog associate with PrintDocument;            printDialog1.Document = printDocument1;               if (printDialog1.ShowDialog()==DialogResult.OK)            {                printDocument1.Print();            }}  private void btnPrintPreview_Click(object sender,  EventArgs e){            //Associate PrintPreviewDialog with PrintDocument.            printPreviewDialog1.Document = printDocument1;                  // Show PrintPreview Dialog            printPreviewDialog1.ShowDialog();}
```

##### Run the project

![PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net](https://www.mindstick.com/mindstickarticle/0bbfc045-89ac-4885-915f-0f03157ec85f/images/d67742a9-c045-4c36-87bf-48fbab9603e7.png)

When you click PrintPreview Button then PrintPreview dialog will open.

![PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net](https://www.mindstick.com/mindstickarticle/0bbfc045-89ac-4885-915f-0f03157ec85f/images/957b3b96-bb8a-485e-b366-feccb0c37f88.png)

When click Print Button then Print dialog will open.

![PrintDocument PrintPreviewDialog and PrintDialog Control in C#.Net](https://www.mindstick.com/mindstickarticle/0bbfc045-89ac-4885-915f-0f03157ec85f/images/cec475c1-eb99-4a81-9e02-d5fa3e5f357e.png)

When you click Print Button then output will goes to the Printer.

---

Original Source: https://www.mindstick.com/articles/425/the-printpreviewdialog-and-printdialog-control-in-c-sharp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
