PrinterSettings.PaperSizes 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取该打印机支持的纸张大小。
public:
property System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ PaperSizes { System::Drawing::Printing::PrinterSettings::PaperSizeCollection ^ get(); };
public System.Drawing.Printing.PrinterSettings.PaperSizeCollection PaperSizes { get; }
member this.PaperSizes : System.Drawing.Printing.PrinterSettings.PaperSizeCollection
Public ReadOnly Property PaperSizes As PrinterSettings.PaperSizeCollection
属性值
PrinterSettings.PaperSizeCollection,它表示此台打印机所支持的纸张大小。
示例
下面的代码示例使用 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)
注解
PrinterSettings.PaperSizeCollection包含PaperSize通过 属性表示纸张大小的PaperSize.Kind实例,该属性包含值之PaperKind一。
通常,通过 PageSettings.PaperSize 属性将页面的纸张大小设置为通过 PaperSizes 集合提供的有效 PaperSize 。
若要指定自定义纸张大小,请参阅 PaperSize 构造函数。