How to use panels

G

Guest

Ok. I am new to desktop apps. I have a form with tool strip at the top and a
split container below it. I have panels in the split container. When I click
on a button in the toolbar, it opens up a user control in the left panel
which consists of buttons. These buttons need to open user control forms in
the right pannel. I can seem to figure out how to open the user control in
the right panel when I click on the buttons in the left panel????
 
M

Morten Wennevik [C# MVP]

Hi Dave,

In the click event of the button try something like

UserControl1 uc = new UserControl1();
splitContainer.Panel2.Controls.Clear();
splitContainer.Panel2.Controls.Add(uc);

Now, you may instead want to create all necessary user controls once at startup and add all of them to splitContainer.Panel2. Then bring the specific UserControl to the front by having it call BringToFront().
 

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

Top