共用方式為


PrinterSettings.PaperSizes 屬性

定義

取得這個印表機支援的紙張大小。

public:
 property System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ PaperSizes { System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ get(); };
public System.Drawing.Printing.PrinterSettings.PaperSizeCollection PaperSizes { get; }
member this.PaperSizes : System.Drawing.Printing.PrinterSettings.PaperSizeCollection
Public ReadOnly Property PaperSizes As PrinterSettings.PaperSizeCollection

屬性值

PrinterSettings.PaperSizeCollection,表示印表機支援的紙張大小。

範例

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

備註

PrinterSettings.PaperSizeCollection包含PaperSize實例,表示透過 PaperSize.Kind 屬性的紙張大小,其中包含其中PaperKind一個值。

一般而言,您可以透過 PageSettings.PaperSize 屬性將頁面的紙張大小設定為可透過PaperSizes集合取得的有效PaperSize紙張大小。

若要指定自定義紙張大小,請參閱建 PaperSize 構函式。

適用於

另請參閱