PropertyDescriptorCollection.Item[] プロパティ

定義

指定した 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

指定したインデックス番号を持つ 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 の位置の数値から 1 を減算する PropertyDescriptor必要があります。 たとえば、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

指定した名前の 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 つの異なるプロパティと見なされます。

こちらもご覧ください

適用対象