PaperSize 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 PaperSize 类的新实例。
重载
| 名称 | 说明 |
|---|---|
| PaperSize() |
初始化 PaperSize 类的新实例。 |
| PaperSize(String, Int32, Int32) |
初始化 PaperSize 类的新实例。 |
注解
下表显示了类实例 PaperSize 的初始属性值。
| 财产 | 初始值 |
|---|---|
| Kind | PaperKind.Custom |
| PaperName | String.Empty |
PaperSize()
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
初始化 PaperSize 类的新实例。
public:
PaperSize();
public PaperSize();
Public Sub New ()
适用于
PaperSize(String, Int32, Int32)
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
- Source:
- PaperSize.cs
初始化 PaperSize 类的新实例。
public:
PaperSize(System::String ^ name, int width, int height);
public PaperSize(string name, int width, int height);
new System.Drawing.Printing.PaperSize : string * int * int -> System.Drawing.Printing.PaperSize
Public Sub New (name As String, width As Integer, height As Integer)
参数
- name
- String
纸张的名称。
- width
- Int32
纸张的宽度,以百分之百为单位。
- height
- Int32
纸张的高度,以百分之百为单位。
示例
下面的代码示例使用打印机支持的纸张大小填充 comboPaperSize 组合框。 此外,还会创建自定义纸张大小并将其添加到组合框中。
PaperName标识为将为通过DisplayMember组合框的属性添加的项提供显示字符串的属性。 该示例假定存在 PrintDocument 名为 printDoc 的变量,并且存在特定的组合框。
// 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)
注解
使用此构造函数创建的构造 PaperSize 函数始终将其 Kind 属性设置为 Custom。 Width只能为自定义PaperSize对象设置属性值和Height属性值。