How do I get the PrintPage event to fire when the user clicks a button?
Here's my code:
public delegate void PrintPageEventHandler(Object sender,PrintPageEventArgs e);
PrintDialog myprintdlg = new PrintDialog();
PrintDocument mypdoc = new PrintDocument();
private void button1_Click(object sender, EventArgs e)
{myprintdlg.Document = mypdoc;
if (myprintdlg.ShowDialog() == DialogResult.OK)
mypdoc.Print();}
public event PrintPageEventHandler PrintPage;
private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
{
string str = richTextBox1.Text;
//formatting omitted to save space
if (str.Length %26gt; chars)
{
str = str.Substring(chars);
e.HasMorePages = true;
}
else
e.HasMorePages = false;
In C# using print dialog box, print contents of richtextBox when user clicks button?
printDocument1.PrintPage += new
System.Drawing.Printing.
PrintPageEventHandler
(this.printDocument1_PrintPage);
tropical flowers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment