指定したインデックス番号を持つ PropertyDescriptor を取得します。
[C#] C# では、このプロパティは PropertyDescriptorCollection クラスのインデクサになります。
Overloads Public Overridable Default ReadOnly Property Item( _
ByVal index As Integer _) As PropertyDescriptor
[C#]
public virtual PropertyDescriptor this[intindex] {get;}
[C++]
public: __property virtual PropertyDescriptor* get_Item(intindex);
[JScript]
returnValue = PropertyDescriptorCollectionObject.Item(index);またはreturnValue = PropertyDescriptorCollectionObject(index);
[JScript] JScript では、この型で定義されている既定のインデックス プロパティを使用することができます。しかし、独自のインデックス プロパティを明示的に定義することはできません。ただし、このクラスの expando 属性を指定すると、既定のインデックス プロパティが提供されます。提供されるインデックス プロパティの型は Object 型であり、インデックス型は String になります。
引数 [JScript]
- index
コレクションから取得する PropertyDescriptor の 0 から始まるインデックス。
パラメータ [Visual Basic, C#, C++]
- index
コレクションから取得する PropertyDescriptor の 0 から始まるインデックス。
プロパティ値
指定したインデックス番号を持つ PropertyDescriptor 。
例外
例外の種類 | 条件 |
---|---|
IndexOutOfRangeException | index パラメータが、 Item に対して有効なインデックスではありません。 |
解説
インデックス番号は 0 から始まっています。したがって、特定の PropertyDescriptor にアクセスするには、その PropertyDescriptor の位置を表す数値から 1 を引いた数値を使用する必要があります。たとえば、3 番目の PropertyDescriptor を取得するには、 myColl[2]
と指定する必要があります。
使用例
[Visual Basic, C#, C++] Item プロパティを使用して、インデックス番号で指定した PropertyDescriptor の名前をテキスト ボックスに出力する例を次に示します。インデックス番号は 0 から始まるため、この例では 2 番目の PropertyDescriptor の名前が出力されます。この例は、 button1
がフォーム上でインスタンス化されていることを前提としています。
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++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
PropertyDescriptorCollection クラス | PropertyDescriptorCollection メンバ | System.ComponentModel 名前空間 | PropertyDescriptorCollection.Item オーバーロードの一覧 | PropertyDescriptor | TypeDescriptor