次の方法で共有


AttributeCollection.Item プロパティ

指定したインデックスの属性を取得します。

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

オーバーロードの一覧

指定した型の属性を取得します。

[Visual Basic] Overloads Public Overridable Default ReadOnly Property Item(Type) As Attribute

[C#] public virtual Attribute this[Type] {get;}

[C++] public: __property virtual Attribute* get_Item(Type*);

[JScript] AttributeCollection.Item (Type)

指定したインデックス番号の属性を取得します。

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

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

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

[JScript] AttributeCollection.Item (int)

使用例

Item プロパティを使用して、インデックス番号で指定した Attribute の名前をテキスト ボックスに出力する例を次に示します。インデックス番号は 0 から始まるため、この例では、2 番目の Attribute の名前がテキスト ボックスに出力されます。この例は、フォーム上に button1textBox1 が作成されていることを前提としています。

 
Private Sub PrintIndexItem
    ' Creates a new collection and assigns it the attributes for button1.
    Dim attributes As AttributeCollection
    attributes = TypeDescriptor.GetAttributes(button1)

    ' Prints the second attribute's name.
    textBox1.Text = attributes(1).ToString
End Sub

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


[C++] 
private:
    void PrintIndexItem() 
    {
        // Creates a new collection and assigns it the attributes for button1.
        AttributeCollection* attributes;
        attributes = TypeDescriptor::GetAttributes( button1 );

        // Prints the second attribute's name.
        textBox1->Text = attributes->Item[ 1 ]->ToString();
    }

[JScript] 
private function PrintIndexItem() {
    // Creates a new collection and assigns it the attributes for button1.
    var attributes : AttributeCollection;
    attributes = TypeDescriptor.GetAttributes(button1);
 
    // Prints the second attribute's name.
    textBox1.Text = attributes[1].ToString();
    Console.WriteLine(textBox1.Text);
 }

参照

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