我想使用 printPreviewDialog 控件。我添加了 4 个控件:richTextBox、按钮、printPreviewDialog 和 printDocument。对于 printDocument1 我添加:
private: System::Void printDocument1_PrintPage(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e) {
printDocument1->Print();
e->Graphics->DrawString(richTextBox1->Text,richTextBox1->Font, Brushes::Black,(float)80,(float)80 );
}
对于按钮:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
printPreviewDialog1->Document = printDocument1;
printPreviewDialog1 -> ShowDialog();
}
代码没问题,我可以构建和运行应用程序。但是当我点击按钮时,我收到了这样的信息:
谁能帮我?多谢你们!