Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a windows form which contains a logo of the company and gridview which consists of set of records(ex: 200 records) and after that in down there is set of text box and label which i need to print altogether.

Is there any way to Print altogether logo with gridview records and textbox and label?

Updated 1-Jul-12 6:08am

1 solution

protected void btnPrint_Click(object sender, EventArgs e)
	PrintDocument pd = new PrintDocument();
	pd.PrintPage += new PrintPageEventHandler(PrintImage);

void PrintImage(object o, PrintPageEventArgs e)
	int x = SystemInformation.WorkingArea.X;
	int y = SystemInformation.WorkingArea.Y;
	int width = this.Width;
	int height = this.Height; 

	Rectangle bounds = new Rectangle(x, y, width, height); 

	Bitmap img = new Bitmap(width, height); 

	this.DrawToBitmap(img, bounds);
	Point p = new Point(100, 100);
	e.Graphics.DrawImage(img, p);    
Share this answer
User CP 1-Jul-12 23:46pm    
Hi Damith,

Thnaks for the responce But If i take the screenshot and print if my gridview contains no of rows which doesn't fit in the window the remaining rows wont print.


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