EventsTab Třída
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
PropertyTab Poskytuje, která může zobrazovat události pro výběr a propojení.
public ref class EventsTab : System::Windows::Forms::Design::PropertyTab
public class EventsTab : System.Windows.Forms.Design.PropertyTab
type EventsTab = class
inherit PropertyTab
Public Class EventsTab
Inherits PropertyTab
- Dědičnost
Příklady
Následující příklad kódu poskytuje příklad EventsTab. Pokud je tato možnost vybrána, zobrazí se EventsTab všechny události v komponentě v pořadí podle typu delegáta.
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>
#using <System.dll>
using namespace System;
using namespace System::ComponentModel;
using namespace System::ComponentModel::Design;
using namespace System::Collections;
using namespace System::Drawing;
using namespace System::IO;
using namespace System::Reflection;
using namespace System::Runtime::Serialization;
using namespace System::Runtime::Serialization::Formatters::Binary;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::Design;
ref class TypeEventsTab;
// This component adds a TypeEventsTab to the Properties Window.
[PropertyTabAttribute(TypeEventsTab::typeid,PropertyTabScope::Document)]
public ref class TypeEventsTabComponent: public 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 ref class TypeEventsTab: public System::Windows::Forms::Design::EventsTab
{
private:
// This string contains a Base-64 encoded and serialized example
// property tab image.
[BrowsableAttribute(true)]
String^ img;
IServiceProvider^ sp;
public:
TypeEventsTab( IServiceProvider^ sp )
: EventsTab( sp )
{
this->sp = sp;
String^ s = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4w"
"LCBDdWx0dXJlPW5ldXRyYW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the properties of the specified component extended with a
// CategoryAttribute reflecting the name of the type of the property.
virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( ITypeDescriptorContext^ /*context*/, Object^ component, array<System::Attribute^>^attributes ) override
{
// Obtain an instance of the IEventBindingService.
IEventBindingService^ eventPropertySvc = dynamic_cast<IEventBindingService^>(sp->GetService( IEventBindingService::typeid ));
// Return if an IEventBindingService could not be obtained.
if ( eventPropertySvc == nullptr )
return gcnew PropertyDescriptorCollection( nullptr );
// 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.
array<EventDescriptor^>^newEvents = gcnew array<EventDescriptor^>(events->Count);
for ( int i = 0; i < events->Count; i++ )
{
array<Attribute^>^temp = {gcnew CategoryAttribute( events[ i ]->EventType->FullName )};
newEvents[ i ] = TypeDescriptor::CreateEvent( events[ i ]->ComponentType, events[ i ], temp );
}
events = gcnew EventDescriptorCollection( newEvents );
// Return event properties for the event descriptors.
return eventPropertySvc->GetEventProperties( events );
}
property String^ TabName
{
// Provides the name for the event property tab.
virtual String^ get() override
{
return "Events by Type";
}
}
};
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";
}
}
}
}
Konstruktory
| Name | Description |
|---|---|
| EventsTab(IServiceProvider) |
Inicializuje novou instanci EventsTab třídy. |
Vlastnosti
| Name | Description |
|---|---|
| Bitmap |
Získá rastrový obrázek, který je zobrazen pro PropertyTab. (Zděděno od PropertyTab) |
| Components |
Získá nebo nastaví pole komponent, ke kterým je karta vlastnosti přidružena. (Zděděno od PropertyTab) |
| HelpKeyword |
Získá klíčové slovo nápovědy pro kartu. |
| TabName |
Získá název karty. |
Metody
| Name | Description |
|---|---|
| CanExtend(Object) |
Získá hodnotu určující, zda zadaný objekt lze rozšířit. |
| Dispose() |
Uvolní všechny prostředky používané PropertyTab. (Zděděno od PropertyTab) |
| Dispose(Boolean) |
Uvolní nespravované prostředky používané PropertyTab a volitelně uvolní spravované prostředky. (Zděděno od PropertyTab) |
| Equals(Object) |
Určuje, zda je zadaný objekt roven aktuálnímu objektu. (Zděděno od Object) |
| GetDefaultProperty(Object) |
Získá výchozí vlastnost ze zadaného objektu. |
| GetHashCode() |
Slouží jako výchozí funkce hash. (Zděděno od Object) |
| GetProperties(ITypeDescriptorContext, Object, Attribute[]) |
Získá všechny vlastnosti karty události, které odpovídají zadaným atributům a kontextu. |
| GetProperties(Object, Attribute[]) |
Získá všechny vlastnosti karty události, které odpovídají zadaným atributům. |
| GetProperties(Object) |
Získá vlastnosti zadané komponenty. (Zděděno od PropertyTab) |
| GetType() |
Získá Type aktuální instance. (Zděděno od Object) |
| MemberwiseClone() |
Vytvoří mělkou kopii aktuálního Object. (Zděděno od Object) |
| ToString() |
Vrátí řetězec, který představuje aktuální objekt. (Zděděno od Object) |