阅读全文:http://www.sufeinet.com/thread-2104-1-1.html

 

       

这一次我们先要研究一下系统的是怎么完成的


           我们使用Reflector反编译一下GroupBox一起来看看它的内部是怎么实现的。

 

从类的开始第一行我们可以看得出来它是继承Control这个类而来的,下面是所有引用的命名空间和继承的源

 

代码
 using System;
    
using System.ComponentModel;
    
using System.Drawing;
    
using System.Drawing.Text;
    
using System.Runtime.InteropServices;
    
using System.Security;
    
using System.Security.Permissions;
    
using System.Windows.Forms.Internal;
    
using System.Windows.Forms.Layout;
    
using System.Windows.Forms.VisualStyles;

    [DefaultEvent(
"Enter"), Designer("System.Windows.Forms.Design.GroupBoxDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"), ClassInterface(ClassInterfaceType.AutoDispatch), DefaultProperty("Text"), ComVisible(true), System.Windows.Forms.SRDescription("DescriptionGroupBox")]
    
public class GroupBox : Control
    {

 

其实这里告诉我们这样几个问题

1.所有引用的命名空间

2.默认的事件 DefaultEvent("Enter"), 

3.在实现设计时服务的类 System.Windows.Forms.Design.GroupBoxDesigner

4.为Com指定接口类型ClassInterface

5.默认的属性DefaultProperty("Text")

6.托管类型或是成员的Com可访问性ComVisible

7.继承自 public class GroupBox : Control

 

关于事件的注册


  我们以一个AutoSizeChanged事件来说明

 

EditorBrowsable(EditorBrowsableState.Always)

 

用上面的语句指定属性和方法是否在编辑器里的可见方式  在这里我们合作Always代表是编辑器里是始终可见的

然后让它显示在属性窗口中

阅读全文:http://www.sufeinet.com/thread-2104-1-1.html

 

 


相关文章:

  • 2022-01-07
  • 2022-01-22
  • 2021-12-07
  • 2021-07-12
  • 2021-10-16
  • 2021-10-04
猜你喜欢
  • 2021-09-10
  • 2021-07-17
  • 2021-10-19
  • 2022-01-07
  • 2021-07-29
  • 2021-12-29
  • 2022-01-01
相关资源
相似解决方案