共用方式為


PrinterSettings.PaperSourceCollection.Item[Int32] 屬性

定義

取得指定之索引處的 PaperSource

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

參數

index
Int32

要取得之 PaperSource 的索引。

屬性值

指定之索引處的 PaperSource

範例

下列程式代碼範例會將 comboPaperSource 印表機支援的紙張來源填入下拉式方塊。 SourceName會識別為 屬性,這個屬性會提供透過下拉式方塊的 屬性新增DisplayMember之項目的顯示字串。 此範例要求 PrintDocument 名為的 printDoc 變數存在,而且特定的下拉式方塊存在。

// Add list of paper sources found on the printer to the combo box.
// The DisplayMember property is used to identify the property that will provide the display String*.
comboPaperSource->DisplayMember = "SourceName";
PaperSource^ pkSource;
for ( int i = 0; i < printDoc->PrinterSettings->PaperSources->Count; i++ )
{
   pkSource = printDoc->PrinterSettings->PaperSources[ i ];
   comboPaperSource->Items->Add( pkSource );
}
// Add list of paper sources found on the printer to the combo box.
// The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSource.DisplayMember="SourceName";

PaperSource pkSource;
for (int i = 0; i < printDoc.PrinterSettings.PaperSources.Count; i++){
    pkSource = printDoc.PrinterSettings.PaperSources[i];
    comboPaperSource.Items.Add(pkSource);
}
' Add list of paper sources found on the printer to the combo box.
' The DisplayMember property is used to identify the property that will provide the display string.
comboPaperSource.DisplayMember = "SourceName"

Dim pkSource As PaperSource
For i = 0 to printDoc.PrinterSettings.PaperSources.Count - 1
    pkSource = printDoc.PrinterSettings.PaperSources.Item(i)
    comboPaperSource.Items.Add(pkSource)
Next

適用於

另請參閱