EventDescriptorCollection Klasa
Definicja
Reprezentuje kolekcję EventDescriptor obiektów.Represents a collection of EventDescriptor objects.
public ref class EventDescriptorCollection : System::Collections::IList
public class EventDescriptorCollection : System.Collections.IList
[System.Runtime.InteropServices.ComVisible(true)]
public class EventDescriptorCollection : System.Collections.IList
type EventDescriptorCollection = class
interface ICollection
interface IEnumerable
interface IList
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
interface IList
interface ICollection
interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
interface ICollection
interface IEnumerable
interface IList
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
interface ICollection
interface IList
interface IEnumerable
Public Class EventDescriptorCollection
Implements IList
- Dziedziczenie
-
EventDescriptorCollection
- Atrybuty
- Implementuje
Przykłady
Poniższy przykład kodu drukuje wszystkie zdarzenia na przycisku w polu tekstowym.The following code example prints all the events on a button in a text box. Wymaga, aby button1
i zostały textBox1
utworzone na formularzu.It requires that button1
and textBox1
have been instantiated on a form.
private:
void MyEventCollection()
{
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
// Displays each event in the collection in a text box.
for each ( EventDescriptor^ myEvent in events )
{
textBox1->Text = String::Concat( textBox1->Text, myEvent->Name, "\n" );
}
}
private void MyEventCollection() {
// Creates a new collection and assigns it the events for button1.
EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
// Displays each event in the collection in a text box.
foreach (EventDescriptor myEvent in events)
textBox1.Text += myEvent.Name + '\n';
}
Private Sub MyEventCollection()
' Creates a new collection and assigns it the events for button1.
Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
' Displays each event in the collection in a text box.
Dim myEvent As EventDescriptor
For Each myEvent In events
textBox1.Text &= myEvent.Name & ControlChars.Cr
Next myEvent
End Sub
Uwagi
EventDescriptorCollection jest tylko do odczytu; nie implementuje metod, które dodają lub usuwają zdarzenia.EventDescriptorCollection is read-only; it does not implement methods that add or remove events. Aby zaimplementować te metody, należy najpierw dziedziczyć z tej klasy.You must inherit from this class to implement these methods.
Korzystając z właściwości dostępnych w EventDescriptorCollection klasie, można wysłać zapytanie do kolekcji o jej zawartości.Using the properties available in the EventDescriptorCollection class, you can query the collection about its contents. Użyj Count właściwości, aby określić liczbę elementów w kolekcji.Use the Count property to determine the number of elements in the collection. Użyj Item[] właściwości, aby uzyskać określoną właściwość według numeru indeksu lub według nazwy.Use the Item[] property to get a specific property by index number or by name.
Możesz również użyć metody, Find Aby uzyskać opis zdarzenia o określonej nazwie z kolekcji.You can also use the Find method to get a description of the event with the specified name from the collection.
Konstruktory
EventDescriptorCollection(EventDescriptor[]) |
Inicjuje nowe wystąpienie EventDescriptorCollection klasy z daną tablicą EventDescriptor obiektów.Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects. |
EventDescriptorCollection(EventDescriptor[], Boolean) |
Inicjuje nowe wystąpienie EventDescriptorCollection klasy z daną tablicą EventDescriptor obiektów.Initializes a new instance of the EventDescriptorCollection class with the given array of EventDescriptor objects. Kolekcja jest opcjonalnie tylko do odczytu.The collection is optionally read-only. |
Pola
Empty |
Określa pustą kolekcję do użycia zamiast tworzenia nowej nie zawierającej żadnych elementów.Specifies an empty collection to use, rather than creating a new one with no items. To |
Właściwości
Count |
Pobiera liczbę deskryptorów zdarzeń w kolekcji.Gets the number of event descriptors in the collection. |
Item[Int32] |
Pobiera lub ustawia zdarzenie o określonym numerze indeksu.Gets or sets the event with the specified index number. |
Item[String] |
Pobiera lub ustawia zdarzenie o określonej nazwie.Gets or sets the event with the specified name. |
Metody
Add(EventDescriptor) |
Dodaje EventDescriptor na końcu kolekcji.Adds an EventDescriptor to the end of the collection. |
Clear() |
Usuwa wszystkie obiekty z kolekcji.Removes all objects from the collection. |
Contains(EventDescriptor) |
Zwraca czy kolekcja zawiera daną wartość EventDescriptor .Returns whether the collection contains the given EventDescriptor. |
Equals(Object) |
Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.Determines whether the specified object is equal to the current object. (Odziedziczone po Object) |
Find(String, Boolean) |
Pobiera opis zdarzenia o określonej nazwie w kolekcji.Gets the description of the event with the specified name in the collection. |
GetEnumerator() |
Pobiera moduł wyliczający dla tego elementu EventDescriptorCollection .Gets an enumerator for this EventDescriptorCollection. |
GetHashCode() |
Służy jako domyślna funkcja skrótu.Serves as the default hash function. (Odziedziczone po Object) |
GetType() |
Pobiera Type bieżące wystąpienie.Gets the Type of the current instance. (Odziedziczone po Object) |
IndexOf(EventDescriptor) |
Zwraca indeks danego elementu EventDescriptor .Returns the index of the given EventDescriptor. |
Insert(Int32, EventDescriptor) |
Wstawia EventDescriptor do kolekcji w określonym indeksie.Inserts an EventDescriptor to the collection at a specified index. |
InternalSort(IComparer) |
Sortuje elementy członkowskie tego elementu EventDescriptorCollection przy użyciu określonego IComparer .Sorts the members of this EventDescriptorCollection, using the specified IComparer. |
InternalSort(String[]) |
Sortuje elementy członkowskie tego elementu EventDescriptorCollection .Sorts the members of this EventDescriptorCollection. Określone zamówienie jest stosowane jako pierwsze, a następnie domyślne sortowanie dla tej kolekcji, która zwykle jest alfabetyczna.The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical. |
MemberwiseClone() |
Tworzy skróconą kopię bieżącego elementu Object .Creates a shallow copy of the current Object. (Odziedziczone po Object) |
Remove(EventDescriptor) |
Usuwa określony EventDescriptor z kolekcji.Removes the specified EventDescriptor from the collection. |
RemoveAt(Int32) |
Usuwa EventDescriptor określony indeks z kolekcji.Removes the EventDescriptor at the specified index from the collection. |
Sort() |
Sortuje elementy członkowskie tego elementu EventDescriptorCollection przy użyciu domyślnego sortowania dla tej kolekcji, która zwykle jest alfabetyczna.Sorts the members of this EventDescriptorCollection, using the default sort for this collection, which is usually alphabetical. |
Sort(IComparer) |
Sortuje elementy członkowskie tego elementu EventDescriptorCollection przy użyciu określonego IComparer .Sorts the members of this EventDescriptorCollection, using the specified IComparer. |
Sort(String[]) |
Sortuje elementy członkowskie tego EventDescriptorCollection , uwzględniając określoną kolejność sortowania.Sorts the members of this EventDescriptorCollection, given a specified sort order. |
Sort(String[], IComparer) |
Sortuje elementy członkowskie tego EventDescriptorCollection , uwzględniając określoną kolejność sortowania i IComparer .Sorts the members of this EventDescriptorCollection, given a specified sort order and an IComparer. |
ToString() |
Zwraca ciąg reprezentujący bieżący obiekt.Returns a string that represents the current object. (Odziedziczone po Object) |
Jawne implementacje interfejsu
ICollection.CopyTo(Array, Int32) |
Kopiuje elementy kolekcji do Array , rozpoczynając od określonego Array indeksu.Copies the elements of the collection to an Array, starting at a particular Array index. |
ICollection.Count |
Pobiera liczbę elementów zawartych w kolekcji.Gets the number of elements contained in the collection. |
ICollection.IsSynchronized |
Pobiera wartość wskazującą, czy dostęp do kolekcji jest synchronizowany.Gets a value indicating whether access to the collection is synchronized. |
ICollection.SyncRoot |
Pobiera obiekt, który może służyć do synchronizowania dostępu do kolekcji.Gets an object that can be used to synchronize access to the collection. |
IEnumerable.GetEnumerator() |
Zwraca moduł wyliczający, który iteruje po kolekcji.Returns an enumerator that iterates through a collection. |
IList.Add(Object) |
Dodaje element do kolekcji.Adds an item to the collection. |
IList.Clear() |
Usuwa wszystkie elementy z kolekcji.Removes all the items from the collection. |
IList.Contains(Object) |
Określa, czy kolekcja zawiera konkretną wartość.Determines whether the collection contains a specific value. |
IList.IndexOf(Object) |
Określa indeks określonego elementu w kolekcji.Determines the index of a specific item in the collection. |
IList.Insert(Int32, Object) |
Wstawia element do kolekcji o określonym indeksie.Inserts an item to the collection at the specified index. |
IList.IsFixedSize |
Pobiera wartość wskazującą, czy kolekcja ma stały rozmiar.Gets a value indicating whether the collection has a fixed size. |
IList.IsReadOnly |
Pobiera wartość wskazującą, czy kolekcja jest przeznaczona tylko do odczytu.Gets a value indicating whether the collection is read-only. |
IList.Item[Int32] |
Pobiera lub ustawia element pod określonym indeksem.Gets or sets the element at the specified index. |
IList.Remove(Object) |
Usuwa pierwsze wystąpienie konkretnego obiektu z kolekcji.Removes the first occurrence of a specific object from the collection. |
IList.RemoveAt(Int32) |
Usuwa element pod określonym indeksem.Removes the item at the specified index. |
Metody rozszerzania
Cast<TResult>(IEnumerable) |
Rzutuje elementy elementu IEnumerable do określonego typu.Casts the elements of an IEnumerable to the specified type. |
OfType<TResult>(IEnumerable) |
Filtruje elementy IEnumerable w oparciu o określony typ.Filters the elements of an IEnumerable based on a specified type. |
AsParallel(IEnumerable) |
Włącza przetwarzanie równoległe zapytania.Enables parallelization of a query. |
AsQueryable(IEnumerable) |
Konwertuje IEnumerable do IQueryable .Converts an IEnumerable to an IQueryable. |