user60229
user60229

Reputation:

Can't assign control to custom winforms panel with VS2008 winforms designer

I inherited the prototypical corporate application with a person form (with address, phone, etc).

Now on that mentioned person form one label+textfield is a child of the form itself and not of the panel it visually belongs to.

How can I change a control's parent from form to an existing panel in VS 2008 designer?

Update:

Ah, it seems to be a problem with the super magic custom group box control my beloved cow orker left for my pleasure. Dragging into a normal group box works ...

Update 2:

With the help of the Document Outline I can see that the custom "GroupBoxExt" we have in the application is defective, dragging a control onto the panel (or just changing position of a control on the panel) assigns it to the form.

Update 3:

Now that I new what was wrong (thanks for the document outline tip) I went of to google and found a custom group box on CodeGuru. The author of that artilce found out you'd need to decorate your custom panel with

[Designer("System.Windows.Forms.Design.ParentControlDesigner, System.Design", typeof(IDesigner))]

to make it behave as a nice container.

Upvotes: 1

Views: 766

Answers (2)

Adam Robinson
Adam Robinson

Reputation: 185643

If you're looking to do this in the designer, what you're looking for is the Document Outline panel (it's under the View menu under "Other Windows"). From there you can drag controls by their name in the outline and reassign the parent.

Hope this helps!

Upvotes: 1

JaredPar
JaredPar

Reputation: 754725

I'm not sure exactly what your asking. Can you try clarifying the scenario a bit?

But if you want to change a controls parent, all you need to do is make that control a child of the panel using the Controls property.

myPanel.Controls.Add(target)

This should update the parent of target to be myPanel.

If you're attempting to do this via the designer, all you need to do is drag the target control onto the panel and that should take care of it.

Upvotes: 0

Related Questions