Sdílet prostřednictvím


PaperSize Konstruktory

Definice

Inicializuje novou instanci PaperSize třídy.

Přetížení

Name Description
PaperSize()

Inicializuje novou instanci PaperSize třídy.

PaperSize(String, Int32, Int32)

Inicializuje novou instanci PaperSize třídy.

Poznámky

Následující tabulka zobrazuje počáteční hodnoty vlastností pro instanci PaperSize třídy.

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

PaperSize()

Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
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
Zdroj:
PaperSize.cs
Zdroj:
PaperSize.cs
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 ve stáích palce.

height
Int32

Výška papíru, ve stovká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 a přidá se do pole se seznamem. Je PaperName identifikován jako vlastnost, která poskytne zobrazovaný řetězec pro položku, která je přidána prostřednictvím DisplayMember vlastnosti pole se seznamem. V příkladu se předpokládá, že PrintDocument existuje proměnná 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

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

Platí pro