ekt
ekt

Reputation: 146

User control inheriting from GroupBox cant be edited in design mode

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

Upvotes: 3

Views: 567

Answers (1)

GuidoG
GuidoG

Reputation: 12014

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.

Upvotes: 2

Related Questions