EventDescriptorCollection.Item[] Właściwość

Definicja

Pobiera określone zdarzenie.

Przeciążenia

Item[Int32]

Pobiera lub ustawia zdarzenie o określonym numerze indeksu.

Item[String]

Pobiera lub ustawia zdarzenie o określonej nazwie.

Item[Int32]

Źródło:
EventDescriptorCollection.cs
Źródło:
EventDescriptorCollection.cs
Źródło:
EventDescriptorCollection.cs

Pobiera lub ustawia zdarzenie o określonym numerze indeksu.

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

Liczba indeksów opartych na zerach EventDescriptor do pobrania lub ustawienia.

Wartość właściwości

Element EventDescriptor z określonym numerem indeksu.

Wyjątki

index nie jest prawidłowym indeksem dla Item[Int32].

Przykłady

Poniższy przykład kodu używa Item[] właściwości do drukowania nazwy EventDescriptor określonej przez numer indeksu w polu tekstowym. Ponieważ numer indeksu jest oparty na zera, w tym przykładzie jest wyświetlana nazwa drugiego EventDescriptorelementu . Wymaga to utworzenia button1textBox1 wystąpienia i utworzenia wystąpienia w formularzu.

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

Uwagi

Liczba indeksów jest oparta na zerowej liczbie. W związku z tym należy odjąć wartość 1 od pozycji liczbowej określonej EventDescriptor w celu uzyskania dostępu do tego EventDescriptorelementu . Aby na przykład uzyskać trzeci EventDescriptorelement , należy określić myColl[2]wartość .

Zobacz też

Dotyczy

Item[String]

Źródło:
EventDescriptorCollection.cs
Źródło:
EventDescriptorCollection.cs
Źródło:
EventDescriptorCollection.cs

Pobiera lub ustawia zdarzenie o określonej nazwie.

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

Nazwa elementu EventDescriptor do pobrania lub ustawienia.

Wartość właściwości

Element EventDescriptor o określonej nazwie lub null jeśli zdarzenie nie istnieje.

Przykłady

Poniższy przykład kodu używa Item[] właściwości do drukowania typu składnika określonego EventDescriptor przez indeks. Wymaga to utworzenia button1textBox1 wystąpienia i utworzenia wystąpienia w formularzu.

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

Uwagi

Właściwość Item[] jest rozróżniana wielkość liter podczas wyszukiwania nazw. Oznacza to, że nazwy "Ename" i "ename" są uważane za dwa różne zdarzenia.

Uwaga

Atrybut HostProtectionAttribute zastosowany do tej klasy ma następującą Resources wartość właściwości: Synchronization. Atrybut HostProtectionAttribute nie ma wpływu na aplikacje pulpitu (które typowo są uruchamiane przez dwukrotne kliknięcie ikony, wpisanie polecenia albo wprowadzenie adresu URL w przeglądarce). Aby uzyskać więcej informacji, zobacz klasę HostProtectionAttribute lub SQL Server Programowanie i atrybuty ochrony hosta.

Zobacz też

Dotyczy