PropertyDescriptorCollection.Item[] Eigenschaft

Definition

Ruft den angegebenen PropertyDescriptor ab oder legt diesen fest.

Überlädt

Item[Int32]

Ruft den PropertyDescriptor an der angegebenen Indexnummer ab oder legt diesen fest.

Item[String]

Ruft den PropertyDescriptor mit dem angegebenen Namen ab oder legt diesen fest.

Item[Int32]

Quelle:
PropertyDescriptorCollection.cs
Quelle:
PropertyDescriptorCollection.cs
Quelle:
PropertyDescriptorCollection.cs

Ruft den PropertyDescriptor an der angegebenen Indexnummer ab oder legt diesen fest.

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

Parameter

index
Int32

Der nullbasierte Index von PropertyDescriptor, der abgerufen oder festgelegt werden soll.

Eigenschaftswert

Die PropertyDescriptor-Klasse mit der angegebenen Indexnummer.

Ausnahmen

Der index-Parameter ist kein gültiger Index für Item[Int32].

Beispiele

Im folgenden Codebeispiel wird die Item[] -Eigenschaft verwendet, um den namen der PropertyDescriptor durch die Indexnummer angegebenen in einem Textfeld auszudrucken. Da die Indexnummer nullbasiert ist, wird in diesem Beispiel der Name des zweiten PropertyDescriptorausgegeben. Es erfordert, dass button1 für ein Formular instanziiert wurde.

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

Hinweise

Die Indexnummer ist nullbasiert. Daher müssen Sie 1 von der numerischen Position einer bestimmten PropertyDescriptor subtrahieren, um auf diese PropertyDescriptorzuzugreifen. Um z. B. den dritten PropertyDescriptorzu erhalten, müssen Sie angeben myColl[2].

Weitere Informationen

Gilt für:

Item[String]

Quelle:
PropertyDescriptorCollection.cs
Quelle:
PropertyDescriptorCollection.cs
Quelle:
PropertyDescriptorCollection.cs

Ruft den PropertyDescriptor mit dem angegebenen Namen ab oder legt diesen fest.

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

Parameter

name
String

Der Name des PropertyDescriptor, das aus der Auflistung abgerufen werden soll.

Eigenschaftswert

Die PropertyDescriptor-Klasse mit dem angegebenen Namen oder null, wenn die Eigenschaft nicht vorhanden ist.

Beispiele

Im folgenden Codebeispiel wird die Item[] -Eigenschaft verwendet, um den Typ der Komponente für die PropertyDescriptor durch den Index angegebene zu drucken. Es erfordert, dass und button1textBox1 auf einem Formular instanziiert wurde.

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

Hinweise

Bei der Item[] Eigenschaft wird bei der Suche nach Namen die Groß-/Kleinschreibung beachtet. Das heißt, die Namen "Pname" und "pname" werden als zwei unterschiedliche Eigenschaften betrachtet.

Weitere Informationen

Gilt für: