PropertyDescriptorCollection.Item[] Propriété

Définition

Obtient ou définit le PropertyDescriptor.

Surcharges

Nom Description
Item[Int32]

Obtient ou définit le PropertyDescriptor numéro d’index spécifié.

Item[String]

Obtient ou définit le PropertyDescriptor nom spécifié.

Item[Int32]

Obtient ou définit le PropertyDescriptor numéro d’index spécifié.

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

Paramètres

index
Int32

Index de base zéro de l’objet PropertyDescriptor à obtenir ou définir.

Valeur de propriété

Avec PropertyDescriptor le numéro d’index spécifié.

Exceptions

Le index paramètre n’est pas un index valide pour Item[Int32].

Exemples

L’exemple de code suivant utilise la Item[] propriété pour imprimer le nom du numéro d’index spécifié dans une zone de PropertyDescriptor texte. Étant donné que le numéro d’index est de base zéro, cet exemple imprime le nom du deuxième PropertyDescriptor. Elle exige qu’elle button1 ait été instanciée sur un formulaire.

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

Remarques

Le numéro d’index est de base zéro. Par conséquent, vous devez soustraire 1 de la position numérique d’un particulier PropertyDescriptor pour y accéder PropertyDescriptor. Par exemple, pour obtenir le troisième PropertyDescriptor, vous devez spécifier myColl[2].

Voir aussi

S’applique à

Item[String]

Obtient ou définit le PropertyDescriptor nom spécifié.

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; }
member this.Item(string) : System.ComponentModel.PropertyDescriptor
Default Public Overridable ReadOnly Property Item(name As String) As PropertyDescriptor

Paramètres

name
String

Nom de la PropertyDescriptor collection à obtenir.

Valeur de propriété

Avec PropertyDescriptor le nom spécifié ou null si la propriété n’existe pas.

Exemples

L’exemple de code suivant utilise la Item[] propriété pour imprimer le type de composant pour l’index PropertyDescriptor spécifié. Elle exige qu’elle button1 ait textBox1 été instanciée sur un formulaire.

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

Remarques

La propriété respecte la Item[] casse lors de la recherche de noms. Autrement dit, les noms « Pname » et « pname » sont considérés comme deux propriétés différentes.

Voir aussi

S’applique à