Hi Expert!
I want to print content of richtextbox control in c#
My line of code as below
Associate control to Print document
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font, Brushes.Black, 100, 20);
e.Graphics.PageUnit = GraphicsUnit.Inch;
}
write code for printing and print preview
private void btnPrint_Click(object sender, EventArgs e)
{
//PrintDialog associate with PrintDocument;
printDialog1.Document = printDocument1;
if (printDialog1.ShowDialog()==DialogResult.OK)
{
printDocument1.Print();
}
}
private void btnPrintPreview_Click(object sender, EventArgs e)
{
//Associate PrintPreviewDialog with PrintDocument.
printPreviewDialog1.Document = printDocument1;
// Show PrintPreview Dialog
printPreviewDialog1.ShowDialog();
}
problem is when we have more text than its fits in one page....... then we have to print it in next page.... I think I have to use e.HasMorePages = True to move to
next page.......... but its not working. its only prints first page until text fits in first page..
Thanks
AVADHESH PATEL
12-Feb-2013