Public class localprinter
{
Private Static printdocument fprintdocument = new printdocument ();
/// <Summary>
/// Get the default printer name of the Local Machine
/// </Summary>
Public static string defaultprinter
{
Get {return fprintdocument. printersettings. printername ;}
}
/// <Summary>
/// Obtain the printer list of the local machine. The first item in the list is the default printer.
/// </Summary>
Public static list <string> getlocalprinters ()
{
List <string> fprinters = new list <string> ();
Fprinters. Add (defaultprinter); // default printer always appears in the first item in the list
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> /// obtain the default printer name of the Local Machine // </Summary> Public static string defaultprinter {get {return fprintdocument. printersettings. printername ;}/// <summary> /// obtain the printer list of the local machine. The first item in the list is the default printer. /// </Summary> Public static list <string> getlocalprinters () {list <string> fprinters = new list <string> (); fprinters. add (defaultprinter); // The default printer always appears in the first 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 );}