PropertyDescriptorCollection.Item[] Eigenschaft

Definition

Dient zum Abrufen oder Festlegen des angegebenen PropertyDescriptorWerts.

Überlädt

Name Beschreibung
Item[Int32]

Ruft die PropertyDescriptor angegebene Indexnummer ab oder legt sie fest.

Item[String]

Dient zum Abrufen oder Festlegen des PropertyDescriptor Mit dem angegebenen Namen.

Item[Int32]

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

Ruft die PropertyDescriptor angegebene Indexnummer ab oder legt sie 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 des PropertyDescriptor abzurufenden oder festzulegenden Indexes.

Eigenschaftswert

Die PropertyDescriptor 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 angegebenen Indexnummer in einem Textfeld zu drucken. Da die Indexnummer nullbasiert ist, wird in diesem Beispiel der Name des zweiten PropertyDescriptorAusdrucks ausgegeben. Es erfordert, dass es button1 auf einem 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 eines bestimmten PropertyDescriptor subtrahieren, um darauf zuzugreifen PropertyDescriptor. Um z. B. den dritten PropertyDescriptorabzurufen, müssen Sie angeben myColl[2].

Weitere Informationen

Gilt für:

Item[String]

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

Dient zum Abrufen oder Festlegen des PropertyDescriptor Mit dem angegebenen Namen.

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 abzurufenden Objekts PropertyDescriptor aus der Sammlung.

Eigenschaftswert

Der PropertyDescriptor 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 den PropertyDescriptor angegebenen Index zu drucken. Dies erfordert button1 und textBox1 wurde auf einem Formular instanziiert.

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 Item[] der Suche nach Namen wird die Groß-/Kleinschreibung beachtet. Das heißt, die Namen "Pname" und "pname" werden als zwei verschiedene Eigenschaften betrachtet.

Weitere Informationen

Gilt für: