private EventDescriptorCollection FilterEvents(EventDescriptorCollection origEvents) { // Create an enumerator containing only the events that are not in the provided list of event names // and fill an array with those selected events IEnumerable<EventDescriptor> selectedEvents = origEvents.OfType<EventDescriptor>().Where(e => _excludeBrowsableEvents.Contains(e.Name)); //IEnumerable<EventDescriptor> selectedEvents = origEvents.OfType<EventDescriptor>().Where(e => !_excludeBrowsableEvents.Contains(e.Name)); EventDescriptor[] descriptors = selectedEvents.ToArray(); // Return an EventDescriptorCollection containing only the filtered descriptors EventDescriptorCollection newCollection = new EventDescriptorCollection(descriptors); return newCollection; }