dymanically creating controls in a split container

G

Guest

I have created a window application in VS 2005 using C#. In the main form, I
added a split container. I added controls to the left panel1 from the toolbox
and they all work fine. I want to respond to events from the controls in the
left panel1 and dynamically instantiate user controls that I have created in
the project. If I drag the user control from the toolbox into the right
panel2, it works fine. I copied they generated code and removed the user
control. In the event code of one of the left panel1 controls, I added the
code and added a .Show() on the user control. When I build and run the app,
then click on the control, the code is being executed to create the user
control but it does not show up. What am I missing? Thanks.
 
G

Guest

You may need something like this:


this.panel1.Controls.AddRange(new System.Windows.Forms.Control[]
{richTextBox1, splitter2, listView1});

This call ensures controls are being loaded into the panel and not onto the
form.
 

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