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 » Articles » ASP.NET/Web Applications »

Printing contents of controls in .Net


Posted Date: 02 Sep 2008    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: Srinivas Member Level: Gold    
Rating: 1 out of 5Points: 5



In some situations we need to print only the contents of the controls

Using the following code we can print the contents of the controls.

for eg say we have a label and textbox and we need to print the values of the controsl



using System.Drawing.Printing;
using System.Drawing;

private void button1_Click(object sender, EventArgs e)
{
PrintDocument demodoc = new PrintDocument();
PrintPreviewDialog printprvdialog = new PrintPreviewDialog();
demodoc.PrintPage += new PrintPageEventHandler(printevent);
printprvdialog.Document = demodoc;
printprvdialog.ShowDialog();
}



private void printevent(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(label1.Text, new Font("Arail",10,FontStyle.Bold), Brushes.Black, 100,200);
e.Graphics.DrawString(textBox1.Text, new Font("Arail", 10, FontStyle.Bold), Brushes.Black, 150, 300);
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Vb.net  .  Printing  .  Controls  .  

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: DropdownList's selected text into TextBox
Previous Resource: DataReader vs. DataSet
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use