views:

40

answers:

0

I've got a user control defined like this :

  public partial class FooControl : UserControl
  {
      private System.Windows.Forms.GroupBox groupBox1;
      ...

I wanted to make groupBox1.Text accessible directly from the designer so I went for the obvious solution and created the following property in my FooControl :

        [CategoryAttribute("Appearance"), DescriptionAttribute("The text associated with this control.")]
        public string Text
        {
            get { return groupBox1.Text; }
            set { groupBox1.Text = value;}
        }

This doesn't work because Text is already defined in my super class (in fact, it's a bit in the dark because of the browseable=false attribute, but I eventually found it) :

  public class UserControl : ContainerControl
    {

        [Bindable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override string Text { get; set; }

An easy workaround is to use "Text2" instead of "Text" as the property name, and in this case everything works fine.

However, if I use override or new, my code compile (and works) but my Text property is not visible in the designer.

What's the reason for this behavior ? Is there a workaround (other than using another property name) ?