EventDescriptorCollection.Item[] Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri a megadott eseményt.
Túlterhelések
| Name | Description |
|---|---|
| Item[Int32] |
Lekéri vagy beállítja az eseményt a megadott indexszámmal. |
| Item[String] |
Lekéri vagy beállítja az eseményt a megadott névvel. |
Item[Int32]
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
Lekéri vagy beállítja az eseményt a megadott indexszámmal.
public:
virtual property System::ComponentModel::EventDescriptor ^ default[int] { System::ComponentModel::EventDescriptor ^ get(int index); };
public virtual System.ComponentModel.EventDescriptor? this[int index] { get; }
public virtual System.ComponentModel.EventDescriptor this[int index] { get; }
member this.Item(int) : System.ComponentModel.EventDescriptor
Default Public Overridable ReadOnly Property Item(index As Integer) As EventDescriptor
Paraméterek
- index
- Int32
A lekérni vagy beállítani kívánt index nullaalapú száma EventDescriptor .
Tulajdonság értéke
A EventDescriptor megadott indexszámmal.
Kivételek
index érvénytelen index a következőhöz Item[Int32]: .
Példák
Az alábbi példakód a Item[] tulajdonság használatával nyomtatja ki az EventDescriptor indexszám által megadott nevet egy szövegmezőben. Mivel az indexszám nulla alapú, ez a példa a második EventDescriptornevét nyomtatja ki. Ehhez szükség van rá, button1 és textBox1 egy űrlapon lettek példányosítva.
private:
void PrintIndexItem()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
// Prints the second event's name.
textBox1->Text = events[ 1 ]->ToString();
}
private void PrintIndexItem() {
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Prints the second event's name.
textBox1.Text = events[1].ToString();
}
Private Sub PrintIndexItem()
' Creates a new collection and assigns it the events for button1.
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
' Prints the second event's name.
textBox1.Text = events(1).ToString()
End Sub
Megjegyzések
Az indexszám nulla alapú. Ezért ki kell vonnia 1-et egy adott EventDescriptor számpozíciójából ahhoz, hogy hozzáférhessen az adotthoz EventDescriptor. A harmadik EventDescriptorlekéréséhez például meg kell adnia myColl[2].
Lásd még
A következőre érvényes:
Item[String]
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
- Forrás:
- EventDescriptorCollection.cs
Lekéri vagy beállítja az eseményt a megadott névvel.
public:
virtual property System::ComponentModel::EventDescriptor ^ default[System::String ^] { System::ComponentModel::EventDescriptor ^ get(System::String ^ name); };
public virtual System.ComponentModel.EventDescriptor this[string name] { get; }
member this.Item(string) : System.ComponentModel.EventDescriptor
Default Public Overridable ReadOnly Property Item(name As String) As EventDescriptor
Paraméterek
- name
- String
A lekérni vagy beállítani kívánt név EventDescriptor .
Tulajdonság értéke
A EventDescriptor megadott névvel, vagy null ha az esemény nem létezik.
Példák
Az alábbi példakód az Item[] index által megadott összetevő típusának nyomtatásához EventDescriptor használja a tulajdonságot. Ehhez szükség van rá, button1 és textBox1 egy űrlapon lettek példányosítva.
private:
void PrintIndexItem2()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
// Sets an EventDescriptor to the specific event.
EventDescriptor^ myEvent = events[ "KeyDown" ];
// Prints the name of the event.
textBox1->Text = myEvent->Name;
}
private void PrintIndexItem2() {
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Sets an EventDescriptor to the specific event.
EventDescriptor myEvent = events["KeyDown"];
// Prints the name of the event.
textBox1.Text = myEvent.Name;
}
Private Sub PrintIndexItem2()
' Creates a new collection and assigns it the events for button1.
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
' Sets an EventDescriptor to the specific event.
Dim myEvent As EventDescriptor = events("KeyDown")
' Prints the name of the event.
textBox1.Text = myEvent.Name
End Sub
Megjegyzések
A Item[] tulajdonság megkülönbözteti a kis- és nagybetűket a nevek keresésekor. Vagyis az "Ename" és az "ename" nevek két különböző eseménynek minősülnek.
Note
Az HostProtectionAttribute osztályra alkalmazott attribútum a következő Resources tulajdonságértéket tartalmazza: Synchronization. Ez HostProtectionAttribute nem érinti az asztali alkalmazásokat (amelyek általában egy ikonra duplán kattintva, egy parancs beírásával vagy egy URL-cím beírásával indulnak el a böngészőben). További információ: HostProtectionAttribute osztály vagy SQL Server Programozási és gazdagépvédelmi attribútumok.