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

适用于

另请参阅