GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / PrintGetPrinterName Method
The printer index. It must be a value from 1 to PrintGetPrintersCount.
Example





In This Topic
PrintGetPrinterName Method (GdPictureImaging)
In This Topic
Returns the name of the printer according to the index you have specified.

You can use the PrintGetPrintersCount method to determine the number of all available printers. The printer index is simply an integer value from 1 to PrintGetPrintersCount.

Syntax
'Declaration
 
Public Function PrintGetPrinterName( _
   ByVal PrinterNo As Integer _
) As String
public string PrintGetPrinterName( 
   int PrinterNo
)
public function PrintGetPrinterName( 
    PrinterNo: Integer
): String; 
public function PrintGetPrinterName( 
   PrinterNo : int
) : String;
public: string* PrintGetPrinterName( 
   int PrinterNo
) 
public:
String^ PrintGetPrinterName( 
   int PrinterNo
) 

Parameters

PrinterNo
The printer index. It must be a value from 1 to PrintGetPrintersCount.

Return Value

The name of the specified printer.
Remarks
It is recommend to use the GetStat method or the PrintGetStat method to identify the specific reason for the method's failure, if any.
Example
Finding out the name of the active printer.
Listing of all available printers.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int printCount = gdpictureImaging.PrintGetPrintersCount();
    string printers = "The number of printers: " + printCount + ".\n";
 
    for (int i = 1; i<=printCount; i++)
    {
        printers += gdpictureImaging.PrintGetPrinterName(i) + "\n";
    }
    MessageBox.Show(printers, "Available printers", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
Changing the active printer.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    int printCount = gdpictureImaging.PrintGetPrintersCount();
    string message = "The number of printers: " + printCount;
    if (printCount > 0)
    {
        gdpictureImaging.PrintSetActivePrinter(gdpictureImaging.PrintGetPrinterName(1));
        message += "\nThe active printer is: " + gdpictureImaging.PrintGetActivePrinter();
    }
    MessageBox.Show(message, "Active printer", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
See Also