PrinterSettings.PaperSizeCollection 类

包含 PaperSize 对象的集合。

**命名空间:**System.Drawing.Printing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Class PaperSizeCollection
    Implements ICollection, IEnumerable
用法
Dim instance As PaperSizeCollection
public class PaperSizeCollection : ICollection, IEnumerable
public ref class PaperSizeCollection : ICollection, IEnumerable
public class PaperSizeCollection implements ICollection, IEnumerable
public class PaperSizeCollection implements ICollection, IEnumerable

备注

PrinterSettings.PaperSizeCollection 包含 PaperSize 实例,该实例通过 PaperSize.Kind 属性(它包含 PaperKind 值之一)表示纸张大小。

通常可以通过 PageSettings.PaperSize 属性将页的纸张大小设置为有效的 PaperSize 实例(可通过 PaperSizes 集合获得)。

若要查找如何指定自定义纸张大小,请参见 PaperSize 构造函数。

示例

下面的代码示例用打印机支持的纸张大小填充 comboPaperSize 组合框。此外,创建自定义纸张大小并将它添加到组合框中。PaperName 被标识为向通过组合框的 DisplayMember 属性添加的项提供显示字符串的属性。该示例要求名为 printDocPrintDocument 变量和特定的组合框都已存在。

' 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)
// 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";
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.set_DisplayMember("PaperName");

PaperSize pkSize;
for (int i = 0; i < printDoc.get_PrinterSettings().get_PaperSizes().
    get_Count(); i++) {
    pkSize = printDoc.get_PrinterSettings().get_PaperSizes().
        get_Item(i);
    comboPaperSize.get_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.get_Items().Add(pkCustomSize1);

继承层次结构

System.Object
  System.Drawing.Printing.PrinterSettings.PaperSizeCollection

线程安全

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PrinterSettings.PaperSizeCollection 成员
System.Drawing.Printing 命名空间
PaperSize 类
PrinterSettings.PaperSizes 属性
PrinterSettings.InstalledPrinters 属性
PrinterSettings.PaperSources 属性
PrinterSettings.PrinterResolutions 属性
ListControl.DisplayMember