gpt4 book ai didi

c# - C# Windows 应用程序中的打印问题 - 始终打印到默认打印机

转载 作者:太空宇宙 更新时间:2023-11-03 18:00:16 25 4
gpt4 key购买 nike

我有以下代码来弹出打印机对话框,但无论我选择什么打印机,它总是打印到默认打印机。

如何分配用户选择的打印机? (从对话窗口)

PrintDialog pdlg = new PrintDialog();

// Show the PrintDialog
if (pdlg.ShowDialog() == DialogResult.OK)
{
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);

// Associate PrintDocument object with the PrintDialog
pdlg.Document = pd;

// Print with the new PrinterSettings
pd.Print();
}

最佳答案

在调用 ShowDialog() 之前,您需要将 PrintDocument 分配给 PrintDialog。

关于c# - C# Windows 应用程序中的打印问题 - 始终打印到默认打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2321412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com