EventsTabとは? わかりやすく解説

EventsTab クラス

選択およびリンクのためのイベント表示できる PropertyTab を提供します

名前空間: System.Windows.Forms.Design
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class EventsTab
    Inherits PropertyTab
public class EventsTab : PropertyTab
public ref class EventsTab : public
 PropertyTab
public class EventsTab extends PropertyTab
public class EventsTab extends
 PropertyTab
使用例使用例

EventsTabコード例次に示します選択すると、EventsTab には、デリゲート型順序に従ってコンポーネントイベントの一覧が表示されます。

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.LinkDemand,
 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/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtgIAAAJCTbYCAAAAAAAANgAAACgAAAANAAAAEAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAADO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/ztbZztbZHh4eHh4eztbZztbZztbZztbZztbZztbZztbZztbZztbZ/87W2c7W2QDBAB4eHh4eHs7W2c7W2c7W2c7W2c7W2c7W2c7W2c7W2f/O1tnO1tnO1tkAwQAeHh4eHh7O1tnO1tnO1tnO1tnO1tnO1tnO1tn/ztbZztbZlJSU////AMEAHh4eHh4eztbZztbZztbZztbZztbZztbZ/87W2c7W2c7W2ZSUlP///wDBAB4eHh4eHs7W2c7W2c7W2c7W2c7W2f/O1tnO1tnO1tnO1tmUlJT///8AwQAeHh4eHh7O1tnO1tnO1tnO1tn/ztbZHh4eHh4eHh4eHh4eHh4e////AIAAHh4eHh4eztbZztbZztbZ/87W2ZSUlP///wDBAADBAADBAADBAADBAACAAB4eHh4eHs7W2c7W2f/O1tnO1tmUlJT///8AwQAAgAAeHh4eHh7O1tnO1tnO1tnO1tnO1tn/ztbZztbZztbZlJSU////AMEAAIAAHh4eHh4eztbZztbZztbZztbZ/87W2c7W2c7W2c7W2ZSUlP///wDBAACAAB4eHh4eHs7W2c7W2c7W2f/O1tnO1tnO1tnO1tnO1tmUlJT///8AwQAAgAAeHh4eHh7O1tnO1tn/ztbZztbZztbZztbZztbZztbZlJSU////AMEAAIAAHh4eHh4eztbZ/87W2c7W2c7W2c7W2c7W2c7W2c7W2ZSUlP///wDBAACAAB4eHs7W2f/O1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/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;
        }
    }
}
#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"
      "LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRt"
      "YXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtgIAAAJCTbYCAAAAAAAANgAAACgAAAANAAAAEAAAAAEAGAAAAAAAAAAAAMQOAADED"
      "gAAAAAAAAAAAADO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/ztbZztbZHh4eHh4eztbZztbZztbZztbZztb"
      "ZztbZztbZztbZztbZ/87W2c7W2QDBAB4eHh4eHs7W2c7W2c7W2c7W2c7W2c7W2c7W2c7W2f/O1tnO1tnO1tkAwQAeHh4eHh7O1tnO1"
      "tnO1tnO1tnO1tnO1tnO1tn/ztbZztbZlJSU////AMEAHh4eHh4eztbZztbZztbZztbZztbZztbZ/87W2c7W2c7W2ZSUlP///wDBAB4"
      "eHh4eHs7W2c7W2c7W2c7W2c7W2f/O1tnO1tnO1tnO1tmUlJT///8AwQAeHh4eHh7O1tnO1tnO1tnO1tn/ztbZHh4eHh4eHh4eHh4eH"
      "h4e////AIAAHh4eHh4eztbZztbZztbZ/87W2ZSUlP///wDBAADBAADBAADBAADBAACAAB4eHh4eHs7W2c7W2f/O1tnO1tmUlJT///8"
      "AwQAAgAAeHh4eHh7O1tnO1tnO1tnO1tnO1tn/ztbZztbZztbZlJSU////AMEAAIAAHh4eHh4eztbZztbZztbZztbZ/87W2c7W2c7W2"
      "c7W2ZSUlP///wDBAACAAB4eHh4eHs7W2c7W2c7W2f/O1tnO1tnO1tnO1tnO1tmUlJT///8AwQAAgAAeHh4eHh7O1tnO1tn/ztbZztb"
      "ZztbZztbZztbZztbZlJSU////AMEAAIAAHh4eHh4eztbZ/87W2c7W2c7W2c7W2c7W2c7W2c7W2ZSUlP///wDBAACAAB4eHs7W2f/O1"
      "tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tnO1tn/Cw==";
      img = s;
   }

   // Returns 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";
      }
   }

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

private:

   // This method can be used to retrieve an Image from a block of 
   // Base64-encoded text.
   Image^ DeserializeFromBase64Text( String^ text )
   {
      Image^ img = nullptr;
      array<Byte>^memBytes = Convert::FromBase64String( text );
      IFormatter^ formatter = gcnew BinaryFormatter;
      MemoryStream^ stream = gcnew MemoryStream( memBytes );
      img = dynamic_cast<Image^>(formatter->Deserialize( stream ));
      stream->Close();
      return img;
   }
};
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
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EventsTab メンバ
System.Windows.Forms.Design 名前空間

EventsTab コンストラクタ


EventsTab プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

EventsTab クラス
System.Windows.Forms.Design 名前空間

EventsTab メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EventsTab クラス
System.Windows.Forms.Design 名前空間

EventsTab メンバ

選択およびリンクのためのイベント表示できる PropertyTab を提供します

EventsTab データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド EventsTab EventsTab クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

EventsTab クラス
System.Windows.Forms.Design 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「EventsTab」の関連用語

EventsTabのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



EventsTabのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS