Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guys,i am working on mid-Term project in C#, this is keeping record of a shop and itand in this I have a Winform application There is a DataGridView and some Controls everything is complete except printing functionality.
Here is link of WinForm : Link of WinForm
I want to Print DataGrid and information from controls, there are some hidden columns in DataGrid which i also want to hide on page.
1st page must contain Company information which is like static,and Supplier information which changes from accordingly.I want to add page header and Total on last page if multiple pages.
here is link about bill format i want to achieve not exactly but something like this:
Link of Bill Format

What I have tried:

I tried PrintDocument following tutt but it turns out designing a page is nightmare for me using e.graphics.....drawing on Coordinates i have to run application again n again to see if i m doing right.
Posted
Updated 23-Oct-18 8:11am
v4

1 solution

Quote:
drawing on Coordinates i have to run application again n again to see if i m doing right

Yes - because you are trying to get the layout correct.

The simplest solution is to implement print preview (as it uses the same code, but prints to the display so it's easy and quick to see what you have.
Then add a PDF print driver (google will find you quite a few) and print to that instead of a genuine printer for testing - it doesn't fill the room with rubbish like an inkjet will.

But start by laying out your page manually on paper and work from that to get your print routine working.

There is an "alternative" to all this - there is a PrintForm component you can add: How to: Print a Form by Using the PrintForm Component (Visual Basic) | Microsoft Docs[^]
BUT - and it's a big BUT! Don't be tempted to use it. It prints the form as you see it, so if half your data is scrolled off the bottom of the DataGridView then it will not get printed, and you can;t make the component print it at all!
Persevere with PrintDocument - it may seem clumsy, but it's very, very effective!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900