EventDescriptorCollection.Item[] Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Ottiene l'evento specificato.
Overload
| Nome | Descrizione |
|---|---|
| Item[Int32] |
Ottiene o imposta l'evento con il numero di indice specificato. |
| Item[String] |
Ottiene o imposta l'evento con il nome specificato. |
Item[Int32]
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
Ottiene o imposta l'evento con il numero di indice specificato.
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
Parametri
- index
- Int32
Numero di indice in base zero dell'oggetto EventDescriptor da ottenere o impostare.
Valore della proprietà
Oggetto EventDescriptor con il numero di indice specificato.
Eccezioni
index non è un indice valido per Item[Int32].
Esempio
Nell'esempio di codice seguente viene utilizzata la Item[] proprietà per stampare il nome dell'oggetto EventDescriptor specificato dal numero di indice in una casella di testo. Poiché il numero di indice è in base zero, in questo esempio viene stampato il nome del secondo EventDescriptoroggetto . Richiede che button1 e textBox1 sia stata creata un'istanza in un modulo.
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
Commenti
Il numero di indice è in base zero. Pertanto, è necessario sottrarre 1 dalla posizione numerica di un particolare EventDescriptor per accedere a tale EventDescriptoroggetto . Ad esempio, per ottenere il terzo EventDescriptor, è necessario specificare myColl[2].
Vedi anche
Si applica a
Item[String]
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
- Origine:
- EventDescriptorCollection.cs
Ottiene o imposta l'evento con il nome specificato.
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
Parametri
- name
- String
Nome dell'oggetto EventDescriptor da ottenere o impostare.
Valore della proprietà
Oggetto EventDescriptor con il nome specificato o null se l'evento non esiste.
Esempio
Nell'esempio di codice seguente viene utilizzata la Item[] proprietà per stampare il tipo del componente per l'oggetto EventDescriptor specificato dall'indice. Richiede che button1 e textBox1 sia stata creata un'istanza in un modulo.
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
Commenti
La Item[] proprietà fa distinzione tra maiuscole e minuscole durante la ricerca di nomi. Ovvero, i nomi "Ename" e "ename" sono considerati due eventi diversi.
Annotazioni
L'attributo HostProtectionAttribute applicato a questa classe ha il valore della proprietà seguente Resources : Synchronization. Non HostProtectionAttribute influisce sulle applicazioni desktop (che in genere vengono avviate facendo doppio clic su un'icona, digitando un comando o immettendo un URL in un browser). Per altre informazioni, vedere la HostProtectionAttribute classe o gli attributi di programmazione e protezione host di SQL Server.