printing

  • Thread starter Thread starter Guest
  • Start date Start date
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);
}
 
Back
Top