PrinterList.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using CefSharp;
  2. using System;
  3. using System.Drawing.Printing;
  4. using System.Windows.Forms;
  5. namespace UAS_Web
  6. {
  7. public partial class PrinterList : Form
  8. {
  9. public IBrowser browser;
  10. public PrintDocument PrintDoc;
  11. public PrinterList(IBrowser br)
  12. {
  13. InitializeComponent();
  14. browser = br;
  15. PrintDoc = PrintFile;
  16. }
  17. private void PrinterList_Load(object sender, EventArgs e)
  18. {
  19. PrintDocument print = new PrintDocument();
  20. comboBox1.SelectedIndex = 0;
  21. string sDefault = print.PrinterSettings.PrinterName;//默认打印机名
  22. foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称
  23. {
  24. Printer.Items.Add(sPrint);
  25. if (sPrint == sDefault)
  26. Printer.SelectedIndex = Printer.Items.IndexOf(sPrint);
  27. }
  28. }
  29. private void PrinterList_Shown(object sender, EventArgs e)
  30. {
  31. TopMost = true;
  32. }
  33. }
  34. }