Adding a panel

  • Thread starter Thread starter Anders Eriksson
  • Start date Start date
A

Anders Eriksson

Hello!

How do I add a panel and get the already existing controls to be included
in the panel?

The only way I have made it work if I create the panel first and then add
the other controls. But often I don't realize that I need to use a panel
until I have done much work and already have controls on the frame.

// Anders
 
You can dinamically add controls to an existing panel using panel's property
Controls.

Panel p = new Panel();
TextBox text = new TextBox();
p.Controls.Add(text);
 
If you are referring to working with the controls in the the visual designer
for Windows Forms, then this is very easy to do. Just select all the
pertinent controls, then drag them as a group into the Panel control. They
will re-parent to the Panel. Alternately, you could cut-and-paste the
controls as well.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top