using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Printing; namespace UAS_MES_NEW.CustomControl.ComBoxWithFocus { public partial class PrinterCombox : UserControl { public PrinterCombox() { InitializeComponent(); } public override string Text { get { return PrinterList.Text; } set { PrinterList.Text = value; } } private void PrinterCombox_Load(object sender, EventArgs e) { PrintDocument print = new PrintDocument(); string sDefault = print.PrinterSettings.PrinterName;//默认打印机名 foreach (string sPrint in PrinterSettings.InstalledPrinters)//获取所有打印机名称 { PrinterList.Items.Add(sPrint); if (sPrint == sDefault) PrinterList.SelectedIndex = PrinterList.Items.IndexOf(sPrint); } } } }