Gets the number of event descriptors in the collection.
[Visual Basic] Public ReadOnly Property Count As Integer [C#] public int Count {get;} [C++] public: __property int get_Count(); [JScript] public function get Count() : int;
The number of event descriptors in the collection.
The Count property can be used to set the limits of a loop that iterates through a collection of objects. If the collection is zero-based, be sure to use "Count- 1" as the upper bound of the loop.
The following example uses the Count property to print the number of events attached to Button1. It assumes that Button1 has been instantianted on a form.
[Visual Basic]
Private Sub GetCount() Dim events As EventDescriptorCollection events = TypeDescriptor.GetEvents(Button1) ' Print the number of events on Button 1 in a text box. TextBox1.Text = events.Count.ToString End Sub
EventDescriptorCollection Class | EventDescriptorCollection Members | System.ComponentModel Namespace | EventDescriptor | TypeDescriptor