PropertyDescriptorCollection.Item[] Vlastnost

Definice

Získá nebo nastaví zadanou PropertyDescriptorhodnotu .

Přetížení

Item[Int32]

Získá nebo nastaví na PropertyDescriptor zadané číslo indexu.

Item[String]

Získá nebo nastaví se PropertyDescriptor zadaným názvem.

Item[Int32]

Zdroj:
PropertyDescriptorCollection.cs
Zdroj:
PropertyDescriptorCollection.cs
Zdroj:
PropertyDescriptorCollection.cs

Získá nebo nastaví na PropertyDescriptor zadané číslo indexu.

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

Parametry

index
Int32

Index PropertyDescriptor od nuly pro získání nebo nastavení.

Hodnota vlastnosti

Se PropertyDescriptor zadaným číslem indexu.

Výjimky

Parametr index není platný index pro Item[Int32].

Příklady

Následující příklad kódu používá Item[] vlastnost k vytištění názvu zadaného PropertyDescriptor číslem indexu v textovém poli. Vzhledem k tomu, že číslo indexu je od nuly, zobrazí se v tomto příkladu název druhého PropertyDescriptorobjektu . Vyžaduje vytvoření button1 instance ve formuláři.

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

Poznámky

Číslo indexu je od nuly. Proto musíte odečíst 1 od číselné pozice konkrétního určitého PropertyDescriptor , abyste k tomu měli přístup PropertyDescriptor. Pokud například chcete získat třetí PropertyDescriptor, musíte zadat myColl[2].

Viz také

Platí pro

Item[String]

Zdroj:
PropertyDescriptorCollection.cs
Zdroj:
PropertyDescriptorCollection.cs
Zdroj:
PropertyDescriptorCollection.cs

Získá nebo nastaví se PropertyDescriptor zadaným názvem.

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

Parametry

name
String

Název objektu, který PropertyDescriptor chcete získat z kolekce.

Hodnota vlastnosti

Se PropertyDescriptor zadaným názvem, nebo null pokud vlastnost neexistuje.

Příklady

Následující příklad kódu používá Item[] vlastnost k tisku typu komponenty určené PropertyDescriptor indexem. Vyžaduje, aby button1 ve formuláři byla vytvořena instance a 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

Poznámky

Při hledání názvů se Item[] ve vlastnosti rozlišují malá a velká písmena. To znamená, že názvy "Pname" a "pname" jsou považovány za dvě různé vlastnosti.

Viz také

Platí pro