printing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am new to c#, I am trying to print the context of a textbox or a combobox.
 
If you want to print the text of textbox or combobox

private void printButton_Click(object sender, EventArgs e)
{
//initialize a print document
PrintDocument printDocument1= new PrintDocument();
//add print page event handler
printDocument1.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler
(this.printDocument1_PrintPage);
printDocument1.Print();
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
//print the contents of textbox
e.Graphics.DrawString(TextBox.Text, new Font("Arial", 80,
FontStyle.Regular), Brushes.Black, 50, 100);
}
 
To print the text of textbox or combobox do this


private void printButton_Click(object sender, EventArgs e)
{
//initialize a print document
PrintDocument printDocument1= new PrintDocument();
//add print page event handler
printDocument1.PrintPage += new
System.Drawing.Printing.PrintPageEventHandler
(this.printDocument1_PrintPage);
printDocument1.Print();
}

private void printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs e)
{
//print the contents of textbox
e.Graphics.DrawString(TextBox.Text, new Font("Arial", 80,
FontStyle.Regular), Brushes.Black, 50, 100);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top