【问题标题】:UserControl - Show properties of inner-control in design-mode properties windowsUserControl - 在设计模式属性窗口中显示内部控件的属性
【发布时间】:2013-05-17 15:35:33
【问题描述】:

我有一个 UserControl 名称 UC1,其中包含 2 个控件(文本框、标签)。之后我创建新的窗口窗体并将 UC1 拖到它上面,我如何在设计模式下的“属性窗口”中读取和写入文本框和标签(在 UC1 内)的所有属性?目前,我只能看到 UC1 的属性,但文本框和标签的属性永远不会显示出来。请...谢谢..

备注:不想逐个创建控件属性,例如:Public Overrides Property blabla As String... End Property

【问题讨论】:

    标签: properties user-controls designmode


    【解决方案1】:

    在 control.cs 中

    [Description("Label displayed in the Control"), Category("Controls")]
        public Label lblCaption
        {
            get { return _lblCaption; }
            set { _lblCaption = value; }
        }
    

    在 control.Designer.cs 中

    public System.Windows.Forms.Label _lblCaption;
    

    为按钮执行此操作

    【讨论】:

      猜你喜欢
      • 2010-09-09
      • 2011-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多