---
title: "Datagridview Printing in C#"  
description: "In this article I am trying to explain the concept of datagridview printing in C#."  
author: "Vijay Shukla"  
published: 2013-06-23  
updated: 2020-01-30  
canonical: https://www.mindstick.com/articles/1356/datagridview-printing-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Datagridview Printing in C#

Today In this article, I am trying to explain the [concept of datagridview](https://www.mindstick.com/Articles/441/cell-formatting-of-datagridview-in-dot-net) printing in C#.\

### Implement Print in datagridview

- Open Visual Studio 2010.
- Create a new project and give an appropriate name.
- Drag and drop datagridview in your form from the toolbox.
- Add data in the datagridview.
- Drag and drop the printDocument from the toolbox.
- Add a button for print on the form.
- Double click to get the click event of a button.
- Write the below code in the print button click event.
- **printDocument1.Print();**
- Double click on the printDocument to get the Print Page event.
- Write the below code for print the datagridview **:-**

```
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);

            dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));
            e.Graphics.DrawImage(bm, 0, 0);
        }
```

**11.** Run the demo project;

#### Output: -

![Datagridview Printing in C#](https://www.mindstick.com/mindstickarticle/2ea844ec-2b41-4a86-b931-fcbc6e4fb6c2/images/1482ef37-31d0-4aee-a320-e8e64c19d228.png)

#### Note: -

Click on the Print button to get the print of this datagridview.

I am saving the print datagridview in the XPS document.

![Datagridview Printing in C#](https://www.mindstick.com/mindstickarticle/2ea844ec-2b41-4a86-b931-fcbc6e4fb6c2/images/949cdd48-27cd-4484-a199-b6954a87c504.png)

---

Original Source: https://www.mindstick.com/articles/1356/datagridview-printing-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
