標籤:style blog color os for re
public class LocalPrinter
{
private static PrintDocument fPrintDocument = new PrintDocument();
/// <summary>
/// 擷取本機預設印表機名稱
/// </summary>
public static String DefaultPrinter
{
get { return fPrintDocument.PrinterSettings.PrinterName; }
}
/// <summary>
/// 擷取原生印表機列表。列表中的第一項就是預設印表機。
/// </summary>
public static List<String> GetLocalPrinters()
{
List<String> fPrinters = new List<string>();
fPrinters.Add(DefaultPrinter); // 預設印表機始終出現在列表的第一項
foreach (String fPrinterName in PrinterSettings.InstalledPrinters)
{
if (!fPrinters.Contains(fPrinterName))
fPrinters.Add(fPrinterName);
}
return fPrinters;
}
}
foreach (String fPrinterName in LocalPrinter.GetLocalPrinters())
{
cbxPos1.Items.Add(fPrinterName);
cxbA41.Items.Add(fPrinterName);
}
public class LocalPrinter { private static PrintDocument fPrintDocument = new PrintDocument(); /// <summary> /// 擷取本機預設印表機名稱 /// </summary> public static String DefaultPrinter { get { return fPrintDocument.PrinterSettings.PrinterName; } } /// <summary> /// 擷取原生印表機列表。列表中的第一項就是預設印表機。 /// </summary> public static List<String> GetLocalPrinters() { List<String> fPrinters = new List<string>(); fPrinters.Add(DefaultPrinter); // 預設印表機始終出現在列表的第一項 foreach (String fPrinterName in PrinterSettings.InstalledPrinters) { if (!fPrinters.Contains(fPrinterName)) fPrinters.Add(fPrinterName); } return fPrinters; } } foreach (String fPrinterName in LocalPrinter.GetLocalPrinters()) { cbxPos1.Items.Add(fPrinterName); cxbA41.Items.Add(fPrinterName); }