Sdílet prostřednictvím


EventDescriptorCollection.Item[] Vlastnost

Definice

Získá zadanou událost.

Přetížení

Name Description
Item[Int32]

Získá nebo nastaví událost se zadaným číslem indexu.

Item[String]

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

Item[Int32]

Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs

Získá nebo nastaví událost se zadaným číslem indexu.

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

Parametry

index
Int32

Číslo indexu založeného na nule, které EventDescriptor chcete získat nebo nastavit.

Hodnota vlastnosti

Hodnota EventDescriptor se zadaným číslem indexu.

Výjimky

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 EventDescriptor čí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 EventDescriptor. Vyžaduje vytvoření button1 instance formuláře textBox1 .

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

Poznámky

Číslo indexu je založené na nule. Proto je nutné odečíst hodnotu 1 od číselné pozice konkrétního EventDescriptor , abyste k němu EventDescriptorměli přístup . Chcete-li například získat třetí EventDescriptor, je třeba zadat myColl[2].

Viz také

Platí pro

Item[String]

Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs
Zdroj:
EventDescriptorCollection.cs

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

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

Parametry

name
String

Název souboru, který EventDescriptor chcete získat nebo nastavit

Hodnota vlastnosti

Hodnota EventDescriptor se zadaným názvem nebo null pokud událost neexistuje.

Příklady

Následující příklad kódu používá Item[] vlastnost k vytištění typu komponenty určené EventDescriptor indexem. Vyžaduje vytvoření button1 instance formuláře textBox1 .

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

Poznámky

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

Poznámka:

Atribut HostProtectionAttribute použitý pro tuto třídu má následující Resources hodnotu vlastnosti: Synchronization. Nemá HostProtectionAttribute vliv na desktopové aplikace (které se obvykle spouští poklikáním na ikonu, zadáním příkazu nebo zadáním adresy URL v prohlížeči). Další informace naleznete v HostProtectionAttribute tématu třídy nebo programování SYSTÉMU SQL Server a atributy ochrany hostitele.

Viz také

Platí pro