PrinterSettings.PaperSizes 属性

获取该打印机支持的纸张大小。

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

语法

声明
Public ReadOnly Property PaperSizes As PaperSizeCollection
用法
Dim instance As PrinterSettings
Dim value As PaperSizeCollection

value = instance.PaperSizes
public PaperSizeCollection PaperSizes { get; }
public:
property PaperSizeCollection^ PaperSizes {
    PaperSizeCollection^ get ();
}
/** @property */
public PaperSizeCollection get_PaperSizes ()
public function get PaperSizes () : PaperSizeCollection

属性值

PrinterSettings.PaperSizeCollection,它表示此台打印机所支持的纸张大小。

备注

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

平台

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 类
PrinterSettings 成员
System.Drawing.Printing 命名空间
PaperSize 类
PrinterSettings.PaperSizeCollection
PrinterSettings.InstalledPrinters 属性
PaperSources
PrinterResolutions
ListControl.DisplayMember