PaperSize.PaperName 属性
获取或设置纸张类型的名称。
**命名空间:**System.Drawing.Printing
**程序集:**System.Drawing(在 system.drawing.dll 中)
语法
声明
Public Property PaperName As String
用法
Dim instance As PaperSize
Dim value As String
value = instance.PaperName
instance.PaperName = value
public string PaperName { get; set; }
public:
property String^ PaperName {
String^ get ();
void set (String^ value);
}
/** @property */
public String get_PaperName ()
/** @property */
public void set_PaperName (String value)
public function get PaperName () : String
public function set PaperName (value : String)
属性值
纸张类型的名称。
异常
异常类型 | 条件 |
---|---|
备注
您只能在 Kind 属性设置为 Custom 时设置纸张名称。
示例
下面的代码示例用打印机支持的纸张大小填充 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);
平台
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 类
PaperSize 成员
System.Drawing.Printing 命名空间
PaperKind 枚举