PaperSize 建構函式

定義

初始化 PaperSize 類別的新執行個體。

多載

PaperSize()

初始化 PaperSize 類別的新執行個體。

PaperSize(String, Int32, Int32)

初始化 PaperSize 類別的新執行個體。

備註

下表顯示 PaperSize 類別執行個體的初始屬性值。

屬性 初始值
Kind PaperKind.Custom
PaperName String.Empty

PaperSize()

來源:
PaperSize.cs
來源:
PaperSize.cs
來源:
PaperSize.cs

初始化 PaperSize 類別的新執行個體。

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

適用於

PaperSize(String, Int32, Int32)

來源:
PaperSize.cs
來源:
PaperSize.cs
來源:
PaperSize.cs

初始化 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)

參數

name
String

紙張名稱。

width
Int32

紙張的寬度,以百分之一英吋為單位。

height
Int32

紙張的高度,以百分之一英吋為單位。

範例

下列程式代碼範例會將 comboPaperSize 印表機支援的紙張大小填入下拉式方塊。 此外,會建立自定義紙張大小,並新增至下拉式方塊。 PaperName會識別為 屬性,以提供透過下拉式方塊的 屬性新增DisplayMember之項目的顯示字串。 此範例假設 PrintDocument 名為 printDoc 的變數存在,而且存在特定的下拉式方塊。

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

備註

使用此建構函式建立的 , PaperSizeKind 屬性一律設定為 CustomWidthHeight 屬性值只能針對自定義PaperSize物件設定。

適用於