---
title: "How to Print TextBox Values and DataGridView using Print Control in Windows Forms in VB.net"  
description: "How to Print TextBox Values and DataGridView using Print Control in Windows Forms in VB.net"  
author: "Sankhadip Ghosh"  
published: 2016-08-17  
updated: 2023-07-06  
canonical: https://www.mindstick.com/forum/34164/how-to-print-textbox-values-and-datagridview-using-print-control-in-windows-forms-in-vb-dot-net  
category: "vb.net"  
tags: ["vb.net"]  
reading_time: 2 minutes  

---

# How to Print TextBox Values and DataGridView using Print Control in Windows Forms in VB.net

Hi,I am [working in Visual](https://answers.mindstick.com/qa/115739/why-is-intellisense-not-working-in-visual-studio-2026) Studio 2010 and [SQL Server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server) 2008 with R2.\
I have a [window Form](https://www.mindstick.com/forum/419/how-to-pass-data-from-one-window-form-to-another) that contains some [textbox](https://www.mindstick.com/forum/12714/dynamic-textbox-in-gridview) and a datagridview. My [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) is how can I print all the textbox and datagridview [values](https://www.mindstick.com/forum/327/sum-textbox-values) using Print [Controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net) with proper page setting.\
Please guide me step by step.thanks in advance.

## Replies

### Reply by Aryan Kumar

Sure, I can help you with that. Here are the steps on how to print textbox values and datagridview using print control in windows forms in VB.NET:

1. Create a new Windows Forms project in VB.NET.
2. Add a PrintDialog control and a PrintPreviewDialog control to the form.
3. Add textbox controls and a datagridview control to the form.
4. Bind the textbox controls and the datagridview control to some data.
5. Add an event handler for the PrintDialog control's PrintPage event.
6. In the event handler, get the print page object and print the textbox values and the datagridview control.

Here is an example of the code you would need to print textbox values and datagridview using print control in windows forms in VB.NET:

VB.Net

```plaintext
Private Sub PrintDialog1_PrintPage(sender As Object, e As System.Windows.Forms.PrintPageEventArgs) Handles PrintDialog1.PrintPage
    ' Get the print page object.
    Dim printPage As System.Drawing.Printing.PrintPage = e.PrintPage

    ' Print the textbox values.
    For Each txt As TextBox In Me.Controls.OfType(Of TextBox)
        txt.Print(printPage)
    Next

    ' Print the datagridview control.
    DataGridView1.Print(printPage)
End Sub
```

This code will create a PrintDialog control and a PrintPreviewDialog control and bind them to the form. The textbox controls and the datagridview control will be bound to some data. The PrintDialog control's PrintPage event handler will be called when the user prints the form. The event handler will get the print page object and print the textbox values and the datagridview control.

### Reply by Anonymous User

Here we are providing some links please open and read correct answer.***I hope these links helpful for you.***[https://www.mindstick.com/Articles/1356/datagridview-printing-in-c-sharp](https://www.mindstick.com/Articles/1356/datagridview-printing-in-c-sharp)\
[https://www.mindstick.com/Articles/300/printdocument-printpreviewdialog-and-printdialog-control-in-vb-dot-net](https://www.mindstick.com/Articles/300/printdocument-printpreviewdialog-and-printdialog-control-in-vb-dot-net)\
[https://www.mindstick.com/Articles/425/printdocument-printpreviewdialog-and-printdialog-control-in-c-sharp-dot-net](https://www.mindstick.com/Articles/425/printdocument-printpreviewdialog-and-printdialog-control-in-c-sharp-dot-net//)\
\
thanks.


---

Original Source: https://www.mindstick.com/forum/34164/how-to-print-textbox-values-and-datagridview-using-print-control-in-windows-forms-in-vb-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
