代码之家  ›  专栏  ›  技术社区  ›  recursive

如何获取用户控件的重写文本属性以显示在VS2005中的表单设计器中?

  •  2
  • recursive  · 技术社区  · 16 年前

    我有一个用户控件,其中包含以下代码。

    [System.ComponentModel.Category("Appearance")]
    public override string Text { ... }
    
    private int myVar;
    [System.ComponentModel.Category("Appearance")]
    public int MyProperty { ... }
    

    MyProperty 在窗体中插入控件时显示在属性网格中,但 Text 没有。我怎样才能看到它?

    1 回复  |  直到 15 年前
        1
  •  6
  •   Jim H.    16 年前

    如果将System.ComponentModel.Browsable(true)属性添加到属性中,它将显示在属性浏览器中。通过上面的例子,我确认了VS2008中的行为。