This documentation is archived and is not being maintained.

EventsTab Class

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

Namespace: System.Windows.Forms.Design
Assembly: System.Windows.Forms (in system.windows.forms.dll)

'Declaration
Public Class EventsTab
	Inherits PropertyTab
'Usage
Dim instance As EventsTab

public class EventsTab extends PropertyTab
public class EventsTab extends PropertyTab
Not applicable.

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

No code example is currently available or this language may not be supported.
package EventsTabExample; 

import System.*;
import System.ComponentModel.*;
import System.ComponentModel.Design.*;
import System.Collections.*;
import System.Drawing.*;
import System.IO.*;
import System.Reflection.*;
import System.Runtime.Serialization.*;
import System.Runtime.Serialization.Formatters.Binary.*;
import System.Windows.Forms.*;
import System.Windows.Forms.Design.*;
   
// This component adds a TypeEventsTab to the Properties Window.
/** @attribute PropertyTabAttribute(TypeEventsTab.class, 
    PropertyTabScope.Document)
 */
public class TypeEventsTabComponent extends Component
{

    public TypeEventsTabComponent()
    {
    } //TypeEventsTabComponent
} //TypeEventsTabComponent
   
// This example events tab lists events by their delegate type.
/** @attribute System.Security.Permissions.PermissionSet(System.Security.
    Permissions.SecurityAction.Demand, Name = "FullTrust")
 */
public class TypeEventsTab extends System.Windows.Forms.Design.EventsTab
{
    /** @attribute BrowsableAttribute(true)
     */
    // This string contains a Base-64 encoded and serialized example 
    // property tab image.
    private String img = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZy"
        + "wgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVR"
        + "va2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXAB"
        + "AAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtgIAAAJCTbYCAAAAAAAANgAAACgAAAANA"
        + "AAAEAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAADO1tnO1tnO1tnO1tnO1t"
        + "nO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/ztbZztbZHh4eHh4eztbZztbZztbZztb"
        + "ZztbZztbZztbZztbZztbZ/87W2c7W2QDBAB4eHh4eHs7W2c7W2c7W2c7W2c7W2c7W"
        + "2c7W2c7W2f/O1tnO1tnO1tkAwQAeHh4eHh7O1tnO1tnO1tnO1tnO1tnO1tnO1tn/z"
        + "tbZztbZlJSU////AMEAHh4eHh4eztbZztbZztbZztbZztbZztbZ/87W2c7W2c7W2Z"
        + "SUlP///wDBAB4eHh4eHs7W2c7W2c7W2c7W2c7W2f/O1tnO1tnO1tnO1tmUlJT///8"
        + "AwQAeHh4eHh7O1tnO1tnO1tnO1tn/ztbZHh4eHh4eHh4eHh4eHh4e////AIAAHh4e"
        + "Hh4eztbZztbZztbZ/87W2ZSUlP///wDBAADBAADBAADBAADBAACAAB4eHh4eHs7W2"
        + "c7W2f/O1tnO1tmUlJT///8AwQAAgAAeHh4eHh7O1tnO1tnO1tnO1tnO1tn/ztbZztb"
        + "ZztbZlJSU////AMEAAIAAHh4eHh4eztbZztbZztbZztbZ/87W2c7W2c7W2c7W2ZSUl"
        + "P///wDBAACAAB4eHh4eHs7W2c7W2c7W2f/O1tnO1tnO1tnO1tnO1tmUlJT///8AwQA"
        + "AgAAeHh4eHh7O1tnO1tn/ztbZztbZztbZztbZztbZztbZlJSU////AMEAAIAAHh4eH"
        + "h4eztbZ/87W2c7W2c7W2c7W2c7W2c7W2c7W2ZSUlP///wDBAACAAB4eHs7W2f/O1tn"
        + "O1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/Cw==";

    private IServiceProvider sp;

    public TypeEventsTab(IServiceProvider sp)
    {
        super(sp);
        this.sp = sp;
    } //TypeEventsTab

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

        // 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.get_Count()];

        for (int i = 0; i < events.get_Count(); i++) {
            newEvents.set_Item(i, TypeDescriptor.CreateEvent(events.
                get_Item(i).get_ComponentType(), events.get_Item(i),
                new Attribute[] { new CategoryAttribute(events.get_Item(i).
                get_EventType().get_FullName()) }));
        }
        events = new EventDescriptorCollection(newEvents);

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

    // Provides the name for the event property tab.
    /** @property 
     */
    public String get_TabName()
    {
        return "Events by Type";
    } //get_TabName

    // Provides an image for the event property tab.
    /** @property
     */
    public System.Drawing.Bitmap get_Bitmap()
    {
        Bitmap bmp = new Bitmap(DeserializeFromBase64Text(img));

        return bmp;
    } //get_Bitmap

    // This method can be used to retrieve an Image from a block of 
    // Base64-encoded text.
    private Image DeserializeFromBase64Text(String text)
    {
         Image img = null;
         ubyte memBytes[] = Convert.FromBase64String(text);
         IFormatter formatter = new BinaryFormatter();
         MemoryStream stream =  new MemoryStream(memBytes);
         img =(Image)formatter.Deserialize(stream);
         stream.Close();
         return img;
    } //DeserializeFromBase64Text
} //TypeEventsTab

System.Object
   System.Windows.Forms.Design.PropertyTab
    System.Windows.Forms.Design.EventsTab

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: