zoukankan      html  css  js  c++  java
  • 让复合控件的子控件获得设计时支持

      假如一个复合控件由一个ToolStript和一个TextBox组成,如何使ToolStript获得设计时支持, 在设计时可以像使用普通ToolStript一样添加/删除控件?

      直接把ToolStript设为Public是无法达到目的的。必须定义一个用于为组件实现设计时服务的Designer

    [Designer(typeof(MyDesigner))]
    public partial class UserControl1 : UserControl

      MyDesigner继承自System.Windows.Forms.Design.ControlDesigner 类, 它提供了一个方法“EnableDesignMode”。使用它将启用子控件的设计时功能,但需要将子控件公开为主控件的属性。

         全部代码如下:

    [Designer(typeof(MyDesigner))]
    public partial class UserControl1 : UserControl
    {
        
    public UserControl1()
        {
            InitializeComponent();
        }
            
        [Browsable(
    false), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        
    public ToolStrip MyToolStrip
        {
            
    get { return this.toolStrip1 ; }
        }
    }

     转自:http://www.cnblogs.com/feiyun0112/archive/2007/04/30/733230.html


  • 相关阅读:
    Spring boot 启动图片
    Spring Cloud 从入门到入门
    理解错误的 Arrays.asList()
    git github 对代码的管理
    【POJ 2154】Color
    CodeForces
    CodeForces
    CodeForces
    CodeForces
    [数据结构]Hash Table(哈希表)
  • 原文地址:https://www.cnblogs.com/ningjing/p/1487078.html
Copyright © 2011-2022 走看看