PrinterSettings.PaperSizeCollection 類別

定義

包含 PaperSize 物件的集合。

public: ref class PrinterSettings::PaperSizeCollection : System::Collections::ICollection
public class PrinterSettings.PaperSizeCollection : System.Collections.ICollection
type PrinterSettings.PaperSizeCollection = class
    interface ICollection
    interface IEnumerable
Public Class PrinterSettings.PaperSizeCollection
Implements ICollection
繼承
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 構函式,以瞭解如何指定自訂紙張大小。

建構函式

PrinterSettings.PaperSizeCollection(PaperSize[])

初始化 PrinterSettings.PaperSizeCollection 類別的新執行個體。

屬性

Count

取得集合中不同紙張大小的數目。

Item[Int32]

取得指定之索引處的 PaperSize

方法

Add(PaperSize)

PrinterResolution 加入至集合結尾。

CopyTo(PaperSize[], Int32)

從指定的索引處開始,複製目前 PrinterSettings.PaperSizeCollection 的內容至指定的陣列。

Equals(Object)

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

(繼承來源 Object)
GetEnumerator()

傳回可逐一查看這個集合的列舉程式。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

如需這個成員的說明,請參閱 CopyTo(Array, Int32)

ICollection.Count

如需這個成員的說明,請參閱 Count

ICollection.IsSynchronized

如需這個成員的說明,請參閱 IsSynchronized

ICollection.SyncRoot

如需這個成員的說明,請參閱 SyncRoot

IEnumerable.GetEnumerator()

如需這個成員的說明,請參閱 GetEnumerator()

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱