Partage via


PaperSize Constructeurs

Définition

Initialise une nouvelle instance de la classe PaperSize.

Surcharges

Nom Description
PaperSize()

Initialise une nouvelle instance de la classe PaperSize.

PaperSize(String, Int32, Int32)

Initialise une nouvelle instance de la classe PaperSize.

Remarques

Le tableau suivant présente les valeurs de propriété initiales d’une instance de PaperSize classe.

Propriété Valeur initiale
Kind PaperKind.Custom
PaperName String.Empty

PaperSize()

Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs

Initialise une nouvelle instance de la classe PaperSize.

public:
 PaperSize();
public PaperSize();
Public Sub New ()

S’applique à

PaperSize(String, Int32, Int32)

Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs
Source:
PaperSize.cs

Initialise une nouvelle instance de la classe PaperSize.

public:
 PaperSize(System::String ^ name, int width, int height);
public PaperSize(string name, int width, int height);
new System.Drawing.Printing.PaperSize : string * int * int -> System.Drawing.Printing.PaperSize
Public Sub New (name As String, width As Integer, height As Integer)

Paramètres

name
String

Nom du papier.

width
Int32

Largeur du papier, en centièmes de pouce.

height
Int32

Hauteur du papier, en centièmes de pouce.

Exemples

L’exemple de code suivant remplit la comboPaperSize zone de liste modifiable avec les tailles de papier prises en charge par l’imprimante. En outre, une taille de papier personnalisée est créée et ajoutée à la zone de liste modifiable. La PaperName propriété est identifiée comme la propriété qui fournira la chaîne d’affichage de l’élément ajouté via la DisplayMember propriété de la zone de liste déroulante. L’exemple suppose 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

Un PaperSize constructeur créé avec ce constructeur a toujours sa Kind propriété définie sur Custom. Les Width valeurs et Height les valeurs de propriété peuvent être définies uniquement pour les objets personnalisés PaperSize .

S’applique à