Il presente articolo è stato tradotto automaticamente. Passare il puntatore sulle frasi nell'articolo per visualizzare il testo originale. Ulteriori informazioni.
Traduzione
Originale
Questo argomento non è stato ancora valutato - Valuta questo argomento

Classe EventsTab

Fornisce un oggetto PropertyTab ciò può visualizzare gli eventi per la selezione e collegare.

Spazio dei nomi:  System.Windows.Forms.Design
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)
[PermissionSetAttribute(SecurityAction.LinkDemand, Name = "FullTrust")]
[PermissionSetAttribute(SecurityAction.InheritanceDemand, Name = "FullTrust")]
public class EventsTab : PropertyTab

Il tipo EventsTab espone i seguenti membri.

  NomeDescrizione
Metodo pubblicoEventsTabInizializza una nuova istanza di EventsTab classe.
In alto
  NomeDescrizione
Proprietà pubblicaBitmapOttiene la bitmap che verrà visualizzato per PropertyTab. (Ereditato da PropertyTab)
Proprietà pubblicaComponentsOttiene o imposta la matrice dei componenti la scheda delle proprietà è associati. (Ereditato da PropertyTab)
Proprietà pubblicaHelpKeywordOttiene la parola chiave della Guida sulla scheda. (Esegue l'override di PropertyTab.HelpKeyword).
Proprietà pubblicaTabNameOttiene il nome della scheda. (Esegue l'override di PropertyTab.TabName).
In alto
  NomeDescrizione
Metodo pubblicoCanExtendottiene un valore che indica se l'oggetto specificato può essere esteso. (Esegue l'override di PropertyTab.CanExtend(Object)).
Metodo pubblicoDispose()Libera tutte le risorse utilizzate da PropertyTab. (Ereditato da PropertyTab)
Metodo protettoDispose(Boolean)Rilascia risorse non gestite utilizzate da PropertyTab e facoltativamente dealloca risorse gestite. (Ereditato da PropertyTab)
Metodo pubblicoEquals(Object) Determina se l'oggetto specificato è uguale all'oggetto corrente. (Ereditato da Object)
Metodo protettoFinalizeConsente a PropertyTab per tentare per liberare risorse ed eseguire altre operazioni di pulitura prima di PropertyTab viene recuperato dalla Garbage Collection. (Ereditato da PropertyTab)
Metodo pubblicoGetDefaultPropertyOttiene la proprietà predefinita dall'oggetto specificato. (Esegue l'override di PropertyTab.GetDefaultProperty(Object)).
Metodo pubblicoGetHashCodeFunge da funzione hash per un determinato tipo. (Ereditato da Object)
Metodo pubblicoGetProperties(Object)Ottiene le proprietà del componente specificata. (Ereditato da PropertyTab)
Metodo pubblicoGetProperties(Object, Attribute[])Ottiene tutte le proprietà della scheda di evento che corrispondono agli attributi specificati. (Esegue l'override di PropertyTab.GetProperties(Object, Attribute[])).
Metodo pubblicoGetProperties(ITypeDescriptorContext, Object, Attribute[])Ottiene tutte le proprietà della scheda di evento che corrispondono agli attributi e il contesto specificato. (Esegue l'override di PropertyTab.GetProperties(ITypeDescriptorContext, Object, Attribute[])).
Metodo pubblicoGetTypeOttiene l'oggetto Type dell'istanza corrente. (Ereditato da Object)
Metodo protettoMemberwiseCloneConsente di creare una copia dei riferimenti dell'oggetto Object corrente. (Ereditato da Object)
Metodo pubblicoToString Restituisce una stringa che rappresenta l'oggetto corrente. (Ereditato da Object)
In alto

Nell'esempio di codice viene fornito un esempio EventsTab. una volta selezionato, EventsTab elenca tutti gli eventi di un componente per tipo delegato.


using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using System.Windows.Forms.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.
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.InheritanceDemand, Name="FullTrust")]
    [System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
    public class TypeEventsTab : System.Windows.Forms.Design.EventsTab
    {
        [BrowsableAttribute(true)]
        // This string contains a Base-64 encoded and serialized example 
        // property tab image.
        private string img = "AAEAAAD/////AQAAAAAAAAAMAgAAAFR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nO1tnO1tnO1tnO1tn/Cw==";
        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";
            }
        }

        // Provides an image for the event property tab.
        public override System.Drawing.Bitmap Bitmap
        {
            get
            {
                Bitmap bmp = new Bitmap(DeserializeFromBase64Text(img));
                return bmp;
            }
        }

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


.NET Framework

Supportato in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supportato in: 4, 3.5 SP1

Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (ruoli di base del server non supportati), Windows Server 2008 R2 (ruoli di base del server supportati con SP1 o versione successiva, Itanium non supportato)

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Qualsiasi membro static (Shared in Visual Basic) pubblico di questo tipo è thread-safe. I membri di istanza non sono garantiti come thread-safe.
Il documento è risultato utile?
(1500 caratteri rimanenti)

Aggiunte alla community

AGGIUNGI
© 2013 Microsoft. Tutti i diritti riservati.