次の方法で共有


PropertyDescriptorCollection.Item プロパティ

指定した PropertyDescriptor を取得します。

[C#] C# では、このプロパティは PropertyDescriptorCollection クラスのインデクサになります。

オーバーロードの一覧

指定した名前の PropertyDescriptor を取得します。

[Visual Basic] Overloads Public Overridable Default ReadOnly Property Item(String) As PropertyDescriptor

[C#] public virtual PropertyDescriptor this[string] {get;}

[C++] public: __property virtual PropertyDescriptor* get_Item(String*);

[JScript] PropertyDescriptorCollection.Item (String)

指定したインデックス番号を持つ PropertyDescriptor を取得します。

[Visual Basic] Overloads Public Overridable Default ReadOnly Property Item(Integer) As PropertyDescriptor

[C#] public virtual PropertyDescriptor this[int] {get;}

[C++] public: __property virtual PropertyDescriptor* get_Item(int);

[JScript] PropertyDescriptorCollection.Item (int)

使用例

[Visual Basic, C#, C++] Item プロパティを使用して、インデックス番号で指定した PropertyDescriptor の名前をテキスト ボックスに出力する例を次に示します。インデックス番号は 0 から始まるため、この例では 2 番目の PropertyDescriptor の名前が出力されます。この例は、 button1 がフォーム上でインスタンス化されていることを前提としています。

[Visual Basic, C#, C++] メモ   ここでは、Item プロパティ (PropertyDescriptorCollection インデクサ) のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。

 
Private Sub PrintIndexItem()
    ' Creates a new collection and assigns it the properties for button1.
    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
       
    ' Prints the second property's name.
    textBox1.Text = properties(1).ToString()
End Sub


[C#] 
private void PrintIndexItem() {
    // Creates a new collection and assigns it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
 
    // Prints the second property's name.
    textBox1.Text = properties[1].ToString();
 }


[C++] 
private:
void PrintIndexItem() {
    // Creates a new collection and assigns it the properties for button1.
    PropertyDescriptorCollection* properties = TypeDescriptor::GetProperties(button1);
 
    // Prints the second property's name.
    textBox1->Text = properties->Item[1]->ToString();
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

参照

PropertyDescriptorCollection クラス | PropertyDescriptorCollection メンバ | System.ComponentModel 名前空間