PropertyDescriptorCollection.Item[] Propiedad

Definición

Obtiene o establece el objeto PropertyDescriptor especificado.

Sobrecargas

Item[Int32]

Obtiene o establece PropertyDescriptor en el número de índice especificado.

Item[String]

Obtiene o establece el objeto PropertyDescriptor con el nombre especificado.

Item[Int32]

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Obtiene o establece PropertyDescriptor en el número de índice especificado.

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

Parámetros

index
Int32

Índice de base cero de PropertyDescriptor que se va a obtener o establecer.

Valor de propiedad

PropertyDescriptor que tiene el número de índice especificado.

Excepciones

El parámetro index no es un índice válido para Item[Int32].

Ejemplos

En el ejemplo de código siguiente se usa la Item[] propiedad para imprimir el nombre del especificado por el número de PropertyDescriptor índice en un cuadro de texto. Dado que el número de índice es de base cero, en este ejemplo se imprime el nombre del segundo PropertyDescriptor. Requiere que button1 se haya creado una instancia en un formulario.

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

Comentarios

El número de índice se basa en cero. Por lo tanto, debe restar 1 de la posición numérica de un determinado PropertyDescriptor para tener acceso a ese PropertyDescriptor. Por ejemplo, para obtener el tercer PropertyDescriptor, debe especificar myColl[2].

Consulte también

Se aplica a

Item[String]

Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs
Source:
PropertyDescriptorCollection.cs

Obtiene o establece el objeto PropertyDescriptor con el nombre especificado.

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

Parámetros

name
String

Nombre del objeto PropertyDescriptor que se va a obtener de la colección.

Valor de propiedad

PropertyDescriptor con el nombre especificado, o null si no existe la propiedad.

Ejemplos

En el ejemplo de código siguiente se usa la Item[] propiedad para imprimir el tipo de componente para el PropertyDescriptor especificado por el índice. Requiere que button1 y textBox1 se hayan creado instancias en un formulario.

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

Comentarios

La Item[] propiedad distingue mayúsculas de minúsculas al buscar nombres. Es decir, los nombres "Pname" y "pname" se consideran dos propiedades diferentes.

Consulte también

Se aplica a