PropertyDescriptorCollection.Item[] Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá nebo nastaví zadaný PropertyDescriptor.
Přetížení
| Name | Description |
|---|---|
| Item[Int32] |
Získá nebo nastaví na zadané číslo indexu PropertyDescriptor . |
| Item[String] |
Získá nebo nastaví PropertyDescriptor se zadaným názvem. |
Item[Int32]
Získá nebo nastaví na zadané číslo indexu PropertyDescriptor .
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 založený na nule, který PropertyDescriptor chcete získat nebo nastavit.
Hodnota vlastnosti
Hodnota PropertyDescriptor se 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 založené na nule, tento příklad vytiskne název druhého PropertyDescriptor. Vyžaduje vytvoření button1 instance formuláře.
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 založené na nule. Proto je nutné odečíst hodnotu 1 od číselné pozice konkrétního PropertyDescriptor , abyste k němu PropertyDescriptorměli přístup . Chcete-li například získat třetí PropertyDescriptor, je třeba zadat myColl[2].
Viz také
Platí pro
Item[String]
Získá nebo nastaví PropertyDescriptor se 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, 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 vytištění typu komponenty určené PropertyDescriptor indexem. Vyžaduje vytvoření button1 instance formuláře 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 Item[] hledání názvů se u 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.