PaperSize 类
指定纸张大小。
**命名空间:**System.Drawing.Printing
**程序集:**System.Drawing(在 system.drawing.dll 中)
语法
声明
<SerializableAttribute> _
Public Class PaperSize
用法
Dim instance As PaperSize
[SerializableAttribute]
public class PaperSize
[SerializableAttribute]
public ref class PaperSize
/** @attribute SerializableAttribute() */
public class PaperSize
SerializableAttribute
public class PaperSize
备注
此类由 PrinterSettings.PaperSizes 和 PageSettings.PaperSize 属性分别用来获取打印机上可用的纸张大小和为页设置纸张大小。
可以使用 PaperSize 构造函数来指定自定义的页大小。只能为自定义 PaperSize 对象设置 Width 和 Height 属性值。
有关打印的更多信息,请参见 System.Drawing.Printing 命名空间概述。
示例
下面的代码示例用打印机支持的纸张大小填充 comboPaperSize
组合框。此外,创建自定义纸张大小并将它添加到组合框中。PaperName 被标识为一种属性,该属性将向通过组合框的 DisplayMember 属性添加的项提供显示字符串。该示例假定名为 printDoc
的变量 PrintDocument 和特定的组合框都已存在。
' 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.PaperSize
线程安全
此类型的任何公共静态(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
请参见
参考
PaperSize 成员
System.Drawing.Printing 命名空间
Kind
PrinterSettings
PrinterSettings.PaperSizes
PageSettings.PaperSize 属性
ListControl.DisplayMember