0

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

3
  • It is not clear how your group box is declared. Does that exist in another base class? Are you talking about "Visual Inheritance"? Commented Feb 13, 2014 at 18:32
  • @ElectricRouge Presumably yes. I have MainForm which inherits from Form :) Commented Feb 13, 2014 at 18:34
  • Yes it Winfroms. @SriramSakthivel all I have done is created a form, which is inherited by othre forms. When this happens, the widgets appear on the children forms where they would be on the parent forms. I am able to move the widgets around on the children forms, except i cant put them into groupboxes (declared in children forms). Commented Feb 13, 2014 at 18:40

1 Answer 1

1

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

4
  • Sorry, the GroupBox is in the dervied form. And the controls I am trying to put into it are from the base class. Ill make sure the controls are atleast protected though Commented Feb 13, 2014 at 18:52
  • @BloonsTowerDefence Fine, that doesn't make much difference try my solution. that should help Commented Feb 13, 2014 at 18:56
  • I was facing the same problem and it was fixed by mouse "right click" suggestion, I am curious @Sriram Sakthival , what right click actually does ? Commented Apr 20, 2018 at 11:51
  • 1
    @mohits00691 I have to admit that I don't know what it does and not sure how I knew this. But that's the way I used to solve this problem. Commented Apr 21, 2018 at 13:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.