Vikasumit

Printing Text Document using .NET 2.0 Code
Author : Sumit Gupta

I was making software recently that needs to print information from database. This information is simple text information that consists of name and address of customer with little more detail of it. Since I need to make it very simple using Crystal report won’t help me much. Also, just for learning you need to learn different things, I try to use Printing method of .NET 2.0 Framework. It goes all smooth with code I found for the same. First Add a PrintDialog box on your Windows Application that gives printing capability. Now Include a Object with its events in your code.

Private WithEvents doctoprint As New Printing.PrintDocument

Once we have these basic Set up now, we can simply copy paste given two function on page to Print document define in FILE_PATH constant.


Now, simply call your PrintDocument() function to start printing of FILE_PATH using your Print Button or menu option.