C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » DataGridView »

Printing Datagridview content in windows aplication using C#.net.


Posted Date: 02 Dec 2008    Resource Type: Code Snippets    Category: DataGridView
Author: bulli guruvu settyMember Level: Gold    
Rating: 1 out of 5Points: 4



* Take one datagridview1 control.
* Take one printdocument1
* & two buttons named as retrive & print.

Develop code for retriving & bind it to the datagridview in retrive button.

Code for Print_click:

private void print_Click(object sender, EventArgs e)
{
printDocument1.Print();
}

Then develop code for printdocument1_printpage event:

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{

Bitmap bm = new Bitmap(this.dataGridView1.Width, this.dataGridView1.Height);

this.dataGridView1.DrawToBitmap(bm, new Rectangle(0, 0, this.dataGridView1.Width, this.dataGridView1.Height));

e.Graphics.DrawImage(bm, 0, 0);
}

Then finally execute the project.It will print the datagrinview content only.



Responses

Author: pradeep    16 Apr 2009Member Level: Bronze   Points : 1
If a datagridview has more rows which is not displayed on the current form then whether its get printed or not. I mean if datagridview has more rows which we have to scroll down then its get printed or not.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Printing Datagridview content  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: BINDING (System.Collections.Generic.List) TO GRIDVIEW
Previous Resource: Retrive value from datagrid
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use