我一直在尝试自己解决这个问题,但我还没有弄清楚。当我按下btn_print
按钮时,我想打开一个打印对话框窗口。我已经指出了一行,我认为不再需要了,因为这是定义打印页面的大小。
有人能看看我的代码,告诉我我能做什么吗?
private void btn_print_Click(object sender, RoutedEventArgs e)
{
try
{
PrintDocument pd = new PrintDocument();
//pd.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1169);
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
pd.Print();
}
catch (Exception ex)
{
MessageBox.Show("An error occurred while printing", ex.ToString());
}
}
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
}
试试这样的东西:
PrintDocument pd = new PrintDocument();
//pd.DefaultPageSettings.PaperSize = new PaperSize("A4", 827, 1169);
pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage);
System.Windows.Forms.PrintDialog p = new System.Windows.Forms.PrintDialog();
p.Document = pd;
if (p.ShowDialog() == System.Windows.Forms.DialogResult.OK)
pd.Print();