C# Printing (RichTextBox)

后端 未结 4 2036
我在风中等你
我在风中等你 2020-12-01 16:57

I want to print the content of my RichTextBox (eintragRichTextBox) I have now this code:

private void druckenPictureBox_Click(object sender, EventArgs e)
{
          


        
4条回答
  •  星月不相逢
    2020-12-01 17:23

    got it..

    on this Place:

    if (printDialog.ShowDialog() == DialogResult.OK)
    {
        StringReader reader = new StringReader(eintragRichTextBox.Text);
        documentToPrint.Print();
        documentToPrint.PrintPage += new PrintPageEventHandler(DocumentToPrint_PrintPage);
    }
    

    I changed to:

    if (printDialog.ShowDialog() == DialogResult.OK)
    {
        StringReader reader = new StringReader(eintragRichTextBox.Text);
        documentToPrint.PrintPage += new PrintPageEventHandler(DocumentToPrint_PrintPage);
        documentToPrint.Print();    
    }
    

    Now it works fine..

    Also if someone needs to print content of a RichTextBox, you can use my code..

提交回复
热议问题