PrinterSettings.PaperSizeCollection PrinterSettings.PaperSizeCollection PrinterSettings.PaperSizeCollection PrinterSettings.PaperSizeCollection Class

定义

包含 PaperSize 对象的集合。Contains a collection of PaperSize objects.

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.PaperSizeCollectionPrinterSettings.PaperSizeCollectionPrinterSettings.PaperSizeCollectionPrinterSettings.PaperSizeCollection
实现

示例

下面的代码示例将用comboPaperSize打印机支持的纸张大小填充组合框。The following code example populates the comboPaperSize combo box with the printer's supported paper sizes. 此外, 还会创建自定义纸张大小, 并将其添加到组合框。In addition, a custom paper size is created and added to the combo box. 标识为属性, 该属性为通过组合框的DisplayMember属性添加的项提供显示字符串。 PaperNameThe PaperName is identified as the property that provides the display string for the item being added through the DisplayMember property of the combo box. 该示例要求名为PrintDocument printDoc的变量存在并且存在特定的组合框。The example requires that a PrintDocument variable named printDoc exists and that the specific combo box exists.

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

注解

包含通过属性表示纸张大小的实例, 该属性包含一个PaperKind值。 PaperSize.Kind PaperSize PrinterSettings.PaperSizeCollectionThe PrinterSettings.PaperSizeCollection contains PaperSize instances that represents the paper sizes through the PaperSize.Kind property, which contains one of the PaperKind values.

通常, 可以通过PageSettings.PaperSize属性将页面的纸张大小设置为通过PaperSizes集合提供PaperSize的有效实例。Typically, you set a page's paper size through the PageSettings.PaperSize property to a valid PaperSize instance available through the PaperSizes collection.

请参阅PaperSize构造函数以了解如何指定自定义纸张大小。See the PaperSize constructor to find out how you can specify a custom paper size.

构造函数

PrinterSettings.PaperSizeCollection(PaperSize[]) PrinterSettings.PaperSizeCollection(PaperSize[]) PrinterSettings.PaperSizeCollection(PaperSize[]) PrinterSettings.PaperSizeCollection(PaperSize[])

初始化 PrinterSettings.PaperSizeCollection 类的新实例。Initializes a new instance of the PrinterSettings.PaperSizeCollection class.

属性

Count Count Count Count

获取集合中不同纸张大小的数目。Gets the number of different paper sizes in the collection.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取指定索引处的 PaperSizeGets the PaperSize at a specified index.

方法

Add(PaperSize) Add(PaperSize) Add(PaperSize) Add(PaperSize)

向集合的末尾添加一个 PrinterResolutionAdds a PrinterResolution to the end of the collection.

CopyTo(PaperSize[], Int32) CopyTo(PaperSize[], Int32) CopyTo(PaperSize[], Int32) CopyTo(PaperSize[], Int32)

将当前 PrinterSettings.PaperSizeCollection 的内容复制到指定数组,从指定索引处开始。Copies the contents of the current PrinterSettings.PaperSizeCollection to the specified array, starting at the specified index.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

返回可循环访问集合的枚举数。Returns an enumerator that can iterate through the collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32)

有关此成员的说明,请参见 CopyTo(Array, Int32)For a description of this member, see CopyTo(Array, Int32).

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

有关此成员的说明,请参见 CountFor a description of this member, see Count.

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

有关此成员的说明,请参见 IsSynchronizedFor a description of this member, see IsSynchronized.

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

有关此成员的说明,请参见 SyncRootFor a description of this member, see SyncRoot.

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

有关此成员的说明,请参见 GetEnumerator()For a description of this member, see GetEnumerator().

扩展方法

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

启用查询的并行化。Enables parallelization of a query.

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

适用于

另请参阅