PrinterSettings.PaperSizeCollection.Item[Int32] 属性

定义

获取指定索引处的 PaperSize

public:
 virtual property System::Drawing::Printing::PaperSize ^ default[int] { System::Drawing::Printing::PaperSize ^ get(int index); };
public virtual System.Drawing.Printing.PaperSize this[int index] { get; }
member this.Item(int) : System.Drawing.Printing.PaperSize
Default Public Overridable ReadOnly Property Item(index As Integer) As PaperSize

参数

index
Int32

要获取的 PaperSize 的索引。

属性值

指定索引处的 PaperSize

示例

下面的代码示例使用 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)

适用于

另请参阅