zoukankan      html  css  js  c++  java
  • C#仿QQ皮肤-GroupBox 控件实现(一)

    阅读全文: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


  • 相关阅读:
    Python异常处理
    Python中的变量作用域,LEGB规则和闭包原理
    Flask实现RESTful API
    Django中自定义实现RESTful API
    Python中的单例模式
    Flask中实现分页
    面向对象进阶
    Flask部分三方模块的使用
    面向对象基础
    在visual studio中设置点击左边选项卡中的类文件,右侧解决方案跳到对应的文件
  • 原文地址:https://www.cnblogs.com/sufei/p/1844539.html
Copyright © 2011-2022 走看看