3

I want to extend a GroupBox by adding a button on the caption. If I do this

public partial class MyInheritedGroupBox : GroupBox
{
    public MyInheritedGroupBox()
    {
        InitializeComponent();
    }
}

Works at runtime, but the control itself can't be edited anymore in the designer. Double clicking on the control now shows this

not the designer I want

Is there some magic attributes so it shows up in the designer?

I'm trying to avoid inheriting from UserControl because it then introduces other complexities like this

ekt
  • 129
  • 2
  • 11

1 Answers1

2

Not sure what you want, there are 2 things that could be possible.

1, After dropping your control on a form you are not able to edit it using the designer and the object inspector. If that is the case you can solve it like this :

[Designer(typeof(ControlDesigner))] //without this you cannot change properties in the designer
public partial class MyInheritedGroupBox : GroupBox
{
    public MyInheritedGroupBox()
    {
       InitializeComponent();
    }
}

2, You want to build your control visually by double clicking on the class in the solution explorer.

If that is the case than you are out of luck.
You will need to create a UserControl for that.

GuidoG
  • 11,359
  • 6
  • 44
  • 79
  • No. That is specifying a designer for when MyInheritedGroupBox is being used in a form. I am talking about designing the control itself, by double clicking over its class. – ekt Aug 25 '17 at 14:25
  • I was afraid that was the answer. Thanks anyway. I edited the original post for clearness. – ekt Aug 25 '17 at 15:08
  • No problem. I do all my inherited controls like this because I hate the UserControl too – GuidoG Aug 25 '17 at 15:14