EventsTab Class

Definition

Provides a PropertyTab that can display events for selection and linking.

C#
public class EventsTab : System.Windows.Forms.Design.PropertyTab
Inheritance
EventsTab

Examples

The following code example provides an example EventsTab. When selected, the EventsTab lists any events on a component in order of delegate type.

C#
using System;
using System.ComponentModel;
using System.ComponentModel.Design;

namespace EventsTabExample
{
    // This component adds a TypeEventsTab to the Properties Window.
    [PropertyTabAttribute(typeof(TypeEventsTab), PropertyTabScope.Document)]
    public class TypeEventsTabComponent : Component
    {
        public TypeEventsTabComponent()
        {
        }
    }

    // This example events tab lists events by their delegate type.
    public class TypeEventsTab : System.Windows.Forms.Design.EventsTab
    {
        [BrowsableAttribute(true)]
        private IServiceProvider sp;

        public TypeEventsTab(IServiceProvider sp) : base(sp)
        {
            this.sp = sp;
        }

        // Returns the properties of the specified component extended with a 
        // CategoryAttribute reflecting the name of the type of the property.
        public override System.ComponentModel.PropertyDescriptorCollection
            GetProperties(ITypeDescriptorContext context, object component,
            System.Attribute[] attributes)
        {
            // Obtain an instance of the IEventBindingService.
            IEventBindingService eventPropertySvc = (IEventBindingService)
                sp.GetService(typeof(IEventBindingService));

            // Return if an IEventBindingService could not be obtained.
            if (eventPropertySvc == null)
                return new PropertyDescriptorCollection(null);

            // Obtain the events on the component.
            EventDescriptorCollection events =
                TypeDescriptor.GetEvents(component, attributes);

            // Create an array of the events, where each event is assigned 
            // a category matching its type.
            EventDescriptor[] newEvents = new EventDescriptor[events.Count];
            for (int i = 0; i < events.Count; i++)
                newEvents[i] = TypeDescriptor.CreateEvent(events[i].ComponentType, events[i],
                    new CategoryAttribute(events[i].EventType.FullName));
            events = new EventDescriptorCollection(newEvents);

            // Return event properties for the event descriptors.
            return eventPropertySvc.GetEventProperties(events);
        }

        // Provides the name for the event property tab.
        public override string TabName
        {
            get
            {
                return "Events by Type";
            }
        }
    }
}

Constructors

EventsTab(IServiceProvider)

Initializes a new instance of the EventsTab class.

Properties

Bitmap

Gets the bitmap that is displayed for the PropertyTab.

(Inherited from PropertyTab)
Components

Gets or sets the array of components the property tab is associated with.

(Inherited from PropertyTab)
HelpKeyword

Gets the Help keyword for the tab.

TabName

Gets the name of the tab.

Methods

CanExtend(Object)

Gets a value indicating whether the specified object can be extended.

Dispose()

Releases all the resources used by the PropertyTab.

(Inherited from PropertyTab)
Dispose(Boolean)

Releases the unmanaged resources used by the PropertyTab and optionally releases the managed resources.

(Inherited from PropertyTab)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetDefaultProperty(Object)

Gets the default property from the specified object.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetProperties(ITypeDescriptorContext, Object, Attribute[])

Gets all the properties of the event tab that match the specified attributes and context.

GetProperties(Object, Attribute[])

Gets all the properties of the event tab that match the specified attributes.

GetProperties(Object)

Gets the properties of the specified component.

(Inherited from PropertyTab)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

Produkt Verzie
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10