如何在我的C#应用程序中打开打印对话框 [英] how to open print dialog box in my c# application
本文介绍了如何在我的C#应用程序中打开打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要打开打印对话框
thanq
i want to open the print dialog box
thanq
推荐答案
您可以使用javascript函数window.print();单击该按钮或页面加载.
您可以在page_load函数中添加以下代码
You can use javascript function window.print(); either on click of the button or on page load.
You can add the following code in page_load function
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(string), "print", "window.print();", true);
与其他任何对话框一样使用:
Use it just like any other dialog:
System.Windows.Controls.PrintDialog dialogue = new System.Windows.Controls.PrintDialog();
DialogResult dr = dialogue.ShowDialog();
if( dr == DialogResult.OK)
{
// Do something
}
dialogue.Dispose();
您可以像这样使用PrintDialog
You can use the PrintDialog like this
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintPage);
PrintDialog pdi = new PrintDialog();
pdi.Document = pd;
if (pdi.ShowDialog() == DialogResult.OK)
{
pd.DocumentName = documentName;
pd.Print();
}
else
{
MessageBox.Show("Print Cancelled");
}
希望对您有帮助
Hope this helps
这篇关于如何在我的C#应用程序中打开打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文