PrinterSettings.PaperSizes Propriété

Définition

Obtient les tailles du papier prises en charge par cette imprimante.

public:
 property System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ PaperSizes { System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ get(); };
public System.Drawing.Printing.PrinterSettings.PaperSizeCollection PaperSizes { get; }
member this.PaperSizes : System.Drawing.Printing.PrinterSettings.PaperSizeCollection
Public ReadOnly Property PaperSizes As PrinterSettings.PaperSizeCollection

Valeur de propriété

PrinterSettings.PaperSizeCollection

Objet PrinterSettings.PaperSizeCollection représentant les tailles du papier prises en charge par cette imprimante.

Exemples

L’exemple de code suivant remplit la comboPaperSize zone de liste déroulante avec les tailles de papier prises en charge par l’imprimante. En outre, un format de papier personnalisé est créé et ajouté à la zone de liste déroulante. Il PaperName est identifié comme la propriété qui fournit la chaîne d’affichage de l’élément ajouté via la DisplayMember propriété de la zone de liste déroulante. L’exemple exige qu’une PrintDocument variable nommée printDoc existe et que la zone de liste déroulante spécifique existe.

// Add list of supported paper sizes found on the printer.
// The DisplayMember property is used to identify the property that will provide the display String*.
comboPaperSize->DisplayMember = "PaperName";
PaperSize^ pkSize;
for ( int i = 0; i < printDoc->PrinterSettings->PaperSizes->Count; i++ )
{
   pkSize = printDoc->PrinterSettings->PaperSizes[ i ];
   comboPaperSize->Items->Add( pkSize );
}

// Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
PaperSize^ pkCustomSize1 = gcnew PaperSize( "First custom size",100,200 );
comboPaperSize->Items->Add( pkCustomSize1 );
// Add list of supported paper sizes found on the printer. 
// The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName";

PaperSize pkSize;
for (int i = 0; i < printDoc.PrinterSettings.PaperSizes.Count; i++){
    pkSize = printDoc.PrinterSettings.PaperSizes[i];
    comboPaperSize.Items.Add(pkSize);
}

// Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
PaperSize pkCustomSize1 = new PaperSize("First custom size", 100, 200);

comboPaperSize.Items.Add(pkCustomSize1);
' Add list of supported paper sizes found on the printer. 
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSize.DisplayMember = "PaperName"

Dim pkSize As PaperSize
For i = 0 to printDoc.PrinterSettings.PaperSizes.Count - 1
    pkSize = printDoc.PrinterSettings.PaperSizes.Item(i)
    comboPaperSize.Items.Add(pkSize)
Next

' Create a PaperSize and specify the custom paper size through the constructor and add to combobox.
Dim pkCustomSize1 As New PaperSize("Custom Paper Size", 100, 200)

comboPaperSize.Items.Add(pkCustomSize1)

Remarques

Contient PrinterSettings.PaperSizeCollection PaperSize des instances qui représentent les tailles de papier par le biais de la PaperSize.Kind propriété, qui contient l’une des PaperKind valeurs.

En règle générale, vous définissez la taille du papier d’une page par le biais de la PageSettings.PaperSize propriété sur une valeur valide PaperSize disponible via la PaperSizes collection.

Pour spécifier un format de papier personnalisé, consultez le PaperSize constructeur.

S’applique à

Voir aussi