Bagikan melalui


PaperSize Konstruktor

Definisi

Menginisialisasi instans baru dari kelas PaperSize.

Overload

Nama Deskripsi
PaperSize()

Menginisialisasi instans baru dari kelas PaperSize.

PaperSize(String, Int32, Int32)

Menginisialisasi instans baru dari kelas PaperSize.

Keterangan

Tabel berikut ini memperlihatkan nilai properti awal untuk instans PaperSize kelas.

Harta benda Nilai awal
Kind PaperKind.Custom
PaperName String.Empty

PaperSize()

Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs

Menginisialisasi instans baru dari kelas PaperSize.

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

Berlaku untuk

PaperSize(String, Int32, Int32)

Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs
Sumber:
PaperSize.cs

Menginisialisasi instans baru dari kelas 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)

Parameter

name
String

Nama kertas.

width
Int32

Lebar kertas, dalam seratus inci.

height
Int32

Tinggi kertas, dalam seratus inci.

Contoh

Contoh kode berikut mengisi kotak comboPaperSize kombo dengan ukuran kertas yang didukung printer. Selain itu, ukuran kertas kustom dibuat dan ditambahkan ke kotak kombo. PaperName diidentifikasi sebagai properti yang akan menyediakan string tampilan untuk item yang ditambahkan melalui DisplayMember properti kotak kombo. Contoh mengasumsikan bahwa PrintDocument variabel bernama printDoc ada dan bahwa kotak kombo tertentu ada.

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

Keterangan

Yang PaperSize dibuat dengan konstruktor ini selalu memiliki propertinya Kind yang diatur ke Custom. Nilai Width properti dan Height hanya dapat diatur untuk objek kustom PaperSize .

Berlaku untuk