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_LabelMachine.CustomControl { 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); } } private void PrinterList_SelectedIndexChanged(object sender, EventArgs e) { PrinterToolTip.SetToolTip(PrinterList, PrinterList.Text); PrinterToolTip.ShowAlways = true; } } }