PaperSize 類別

定義

指定紙張的大小。

public ref class PaperSize
public class PaperSize
[System.Serializable]
public class PaperSize
type PaperSize = class
[<System.Serializable>]
type PaperSize = class
Public Class PaperSize
繼承
PaperSize
屬性

範例

下列程式代碼範例會將 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)

備註

PageSettings.PaperSize 屬性會使用此PrinterSettings.PaperSizes類別來取得印表機上可用的紙張大小,以及分別設定頁面的紙張大小。

您可以使用 建 PaperSize 構函式來指定自訂紙張大小。 WidthHeight 屬性值只能設定為自定義PaperSize物件。

如需列印的詳細資訊,請參閱 System.Drawing.Printing 命名空間概觀。

建構函式

PaperSize()

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

PaperSize(String, Int32, Int32)

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

屬性

Height

取得或設定紙張的高度,以百分之一英吋為單位。

Kind

取得紙張的類型。

PaperName

取得或設定紙張類型的名稱。

RawKind

取得或設定整數,表示其中一個 PaperSize 值或自訂值。

Width

取得或設定紙張的寬度,以百分之一英吋為單位。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

以字串形式提供 PaperSize 的相關資訊。

適用於

另請參閱