PaperSize Konstruktory

Definice

Inicializuje novou instanci PaperSize třídy .

Přetížení

PaperSize()

Inicializuje novou instanci PaperSize třídy .

PaperSize(String, Int32, Int32)

Inicializuje novou instanci PaperSize třídy .

Poznámky

V následující tabulce jsou uvedeny počáteční hodnoty vlastností pro instanci PaperSize třídy.

Vlastnost Počáteční hodnota
Kind PaperKind.Custom
PaperName String.Empty

PaperSize()

Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs

Inicializuje novou instanci PaperSize třídy .

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

Platí pro

PaperSize(String, Int32, Int32)

Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs

Inicializuje novou instanci PaperSize třídy .

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)

Parametry

name
String

Název papíru.

width
Int32

Šířka papíru, v setinách palce.

height
Int32

Výška papíru, v setinách palce.

Příklady

Následující příklad kódu naplní comboPaperSize pole se seznamem podporovanými formáty papíru tiskárny. Kromě toho se vytvoří vlastní formát papíru, který se přidá do pole se seznamem. Je PaperName identifikován jako vlastnost, která poskytne zobrazovaný řetězec pro položku, která se přidává prostřednictvím DisplayMember vlastnosti pole se seznamem. Příklad předpokládá, že existuje proměnná PrintDocument s názvem printDoc a že existuje konkrétní pole se seznamem.

// 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)

Poznámky

Objekt PaperSize vytvořený pomocí tohoto konstruktoru má vždy vlastnost Kind nastavenou na Custom. Hodnoty Width vlastností a Height lze nastavit pouze pro vlastní PaperSize objekty.

Platí pro