PropertyDescriptorCollection.Item[] プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
指定した PropertyDescriptorを取得または設定します。
オーバーロード
| 名前 | 説明 |
|---|---|
| Item[Int32] |
指定したインデックス番号の PropertyDescriptor を取得または設定します。 |
| Item[String] |
指定した名前の PropertyDescriptor を取得または設定します。 |
Item[Int32]
指定したインデックス番号の PropertyDescriptor を取得または設定します。
public:
virtual property System::ComponentModel::PropertyDescriptor ^ default[int] { System::ComponentModel::PropertyDescriptor ^ get(int index); };
public virtual System.ComponentModel.PropertyDescriptor this[int index] { get; }
member this.Item(int) : System.ComponentModel.PropertyDescriptor
Default Public Overridable ReadOnly Property Item(index As Integer) As PropertyDescriptor
パラメーター
- index
- Int32
取得または設定する PropertyDescriptor の 0 から始まるインデックス。
プロパティ値
指定したインデックス番号を持つ PropertyDescriptor 。
例外
index パラメーターは、Item[Int32]の有効なインデックスではありません。
例
次のコード例では、 Item[] プロパティを使用して、インデックス番号で指定された PropertyDescriptor の名前をテキスト ボックスに出力します。 インデックス番号は 0 から始まるため、この例では 2 番目の PropertyDescriptorの名前を出力します。 フォームで button1 がインスタンス化されている必要があります。
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();
}
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();
}
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
注釈
インデックス番号は 0 から始まります。 したがって、そのPropertyDescriptorにアクセスするには、特定のPropertyDescriptorの数値位置から 1 を減算する必要があります。 たとえば、3 番目の PropertyDescriptorを取得するには、 myColl[2]を指定する必要があります。
こちらもご覧ください
適用対象
Item[String]
指定した名前の PropertyDescriptor を取得または設定します。
public:
virtual property System::ComponentModel::PropertyDescriptor ^ default[System::String ^] { System::ComponentModel::PropertyDescriptor ^ get(System::String ^ name); };
public virtual System.ComponentModel.PropertyDescriptor? this[string name] { get; }
public virtual System.ComponentModel.PropertyDescriptor this[string name] { get; }
member this.Item(string) : System.ComponentModel.PropertyDescriptor
Default Public Overridable ReadOnly Property Item(name As String) As PropertyDescriptor
パラメーター
- name
- String
コレクションから取得する PropertyDescriptor の名前。
プロパティ値
指定した名前の PropertyDescriptor 。プロパティが存在しない場合は null 。
例
次のコード例では、 Item[] プロパティを使用して、インデックスで指定された PropertyDescriptor のコンポーネントの型を出力します。 フォームで button1 と textBox1 がインスタンス化されている必要があります。
void PrintIndexItem2()
{
// Creates a new collection and assigns it the properties for button1.
PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
// Sets a PropertyDescriptor to the specific property.
PropertyDescriptor^ myProperty = properties[ "Opacity" ];
// Prints the display name for the property.
textBox1->Text = myProperty->DisplayName;
}
private void PrintIndexItem2() {
// Creates a new collection and assigns it the properties for button1.
PropertyDescriptorCollection properties =
TypeDescriptor.GetProperties(button1);
// Sets a PropertyDescriptor to the specific property.
PropertyDescriptor myProperty = properties["Opacity"];
// Prints the display name for the property.
textBox1.Text = myProperty.DisplayName;
}
Private Sub PrintIndexItem2()
' Creates a new collection and assigns it the properties for button1.
Dim properties As PropertyDescriptorCollection = _
TypeDescriptor.GetProperties(button1)
' Sets a PropertyDescriptor to the specific property.
Dim myProperty As PropertyDescriptor = properties("Opacity")
' Prints the display name for the property.
textBox1.Text = myProperty.DisplayName
End Sub
注釈
Item[] プロパティは、名前を検索するときに大文字と小文字が区別されます。 つまり、名前 "Pname" と "pname" は 2 つの異なるプロパティと見なされます。