C# 使用对话框为应用设置打印机

C# 使用对话框为应用设置打印机,c#,wpf,C#,Wpf,我的应用程序打印时不显示PrintDialog(它需要这样做),但我希望能够设置它应该打印到哪台打印机,因此我在app.config中添加了一个appsetting,它在其中存储打印机名称。我想要的是一个对话框,其中显示所有打印机,用户应该能够选择打印机,并将其保存在app.config中(实际上,我可以从PrintDialog中执行此操作,并获取所选打印机,但按钮上显示Print,我不想让用户混淆…) 谢谢 编辑 @methodMan要求提供代码,所以我添加了代码 System.Window

我的应用程序打印时不显示PrintDialog(它需要这样做),但我希望能够设置它应该打印到哪台打印机,因此我在app.config中添加了一个appsetting,它在其中存储打印机名称。我想要的是一个对话框,其中显示所有打印机,用户应该能够选择打印机,并将其保存在app.config中(实际上,我可以从PrintDialog中执行此操作,并获取所选打印机,但按钮上显示Print,我不想让用户混淆…) 谢谢
编辑
@methodMan要求提供代码,所以我添加了代码

 System.Windows.Forms.PrintDialog ps = new  System.Windows.Forms.PrintDialog();
      //set the selected printer in the dialog to the current printer 
       ps.PrinterSettings.PrinterName = MyApp.Properties.Settings.Default.ContinuesLabelPrinter;
       var result =  ps.ShowDialog();
        if(result ==  System.Windows.Forms.DialogResult.OK)
        {
            MyApp.Properties.Settings.Default.ContinuesLabelPrinter = ps.PrinterSettings.PrinterName;
        }

好的,我想这是一个适合你的东西…创建一个带有列表框和两个按钮的windows窗体

public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
    }

    private void Form2_Load(object sender, EventArgs e)
    {
        foreach (string printer in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
        {
            listBox1.Items.Add(printer);
        }
    }

    private void button1_Click(object sender, EventArgs e)
    {
        this.Close();
    }

    private void button2_Click(object sender, EventArgs e)
    {
        this.DialogResult = System.Windows.Forms.DialogResult.OK;
    }
}
在代码中执行以下操作:

    Form2 form2 = new Form2();
    if(form2.Show() ==  System.Windows.Forms.DialogResult.OK)
    {
        MyApp.Properties.Settings.Default.ContinuesLabelPrinter = form2.listBox1.SelectedItem.ToString();
    }

    form2.Dispose();  // <-- this might not be necessary
Form2 Form2=new Form2();
if(form2.Show()==System.Windows.Forms.DialogResult.OK)
{
MyApp.Properties.Settings.Default.ContinuesLabelPrinter=form2.listBox1.SelectedItem.ToString();
}

form2.Dispose();//那么,在看不到现有代码的情况下,您希望有人如何帮助您呢。。你看过如何提问吗?还有关于你想要什么到目前为止你自己做了什么。。任何研究…?我会教育用户并使用PrintDialog PrintDialog=new PrintDialog();通过对话框打印非常常见,每个人都应该知道如何使用它。@打印必须像快速打印一样无缝,但用户必须能够设置打印机(而不是将默认打印机设置为该打印机)我所说的混淆用户的意思是,printDialog标题说的是print,所以他会认为他正在打印,而实际上他正在打印not@MethodManIv'e编辑了我的问题添加了我的代码这里是
PrintDialog类
,页面底部有一个工作示例。。另外,请告诉我们您是否已通过逐行调试代码