BloonsTowerDefence
BloonsTowerDefence

Reputation: 1204

Can't add inherited controls to GroupBox

Problem:

I cannot add any controls to a groupbox, if the controls were declared in another form.


Background Information:

I have MainForm which inherits from Form. It provides some functionality which I need in all of my forms, and have also added some custom controls/images which I need in all of the other forms.

With my forms, I reposition the controls/images from the MainForm to wherever I need and all is well.

But for some reason, I cannot move these same controls/images into existing GroupBoxes.

When I say can't I mean that VS is not letting me; when I drag the control over the groupbox, my mouse cursor switches to this "error" sign:

enter image description here

Upvotes: 0

Views: 1088

Answers (1)

Sriram Sakthivel
Sriram Sakthivel

Reputation: 73462

If I understand correctly then you have two or more level of inheritance hierarchy with your form, base class have the GroupBox you're trying to modify it in designer via derived form. Am I correct?

In that case VS prevents you to move control to groupbox which is declared in base class?

If yes, There are couple of things to check.

  1. Check whether your groupbox is atleast protected, so that you can access it in derived class.
  2. If yes, While you're dragging the control just right click the mouse(holding left button), then drop it into groupbox. It should work.

If you have troubles yet make the groupbox as protected internal and give a try.

Hope this helps

Upvotes: 1

Related Questions