473,698 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How load user control into panel on split container in Win app?

I have a Windows app with a split container (SplitContainer 1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.

Can someone please tell me the line(s) of code to do that?

Also, is there an easy/dynamic way to unload whichever user control is
already in there? I'm assuming only one can be in there at a time, right?

Thanks,
Ron
Feb 15 '07 #1
2 13581
Try this:
Panel2.controls .add(utcMyTest)

to unload:
Panel2.controls .remove(utcMyTe st)

---
Another way to load multiple controls is:
Panel2.controls .AddRange(new control() {MyArrayOfContr ols})

Hope this helps.
"Ronald S. Cook" <rc***@westinis .comwrote in message
news:OU******** ******@TK2MSFTN GP06.phx.gbl...
>I have a Windows app with a split container (SplitContainer 1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.

Can someone please tell me the line(s) of code to do that?

Also, is there an easy/dynamic way to unload whichever user control is
already in there? I'm assuming only one can be in there at a time, right?

Thanks,
Ron

Feb 16 '07 #2
Ronald S. Cook wrote:
I have a Windows app with a split container (SplitContainer 1) that contains
two panels (Panel1, Panel2).

I would like to load a user control (utcMyTest) into Panel2 on form load.
utcMyTest = New ....
Panel2.Controls .Add( utcMyTest )
Also, is there an easy/dynamic way to unload whichever user control is
already in there?
Just in case you manage to get more than one in there ...

For i As Integer = Panel2.Controls .Count - 1 To 0 Step -1
Panel2.Controls .Remove( Panel2.Controls .Item(i) )
Next

A For Each loop /might/ work, but you would be removing items from a
collection as you loop through it - generally not a good idea.

HTH,
Phill W.
Feb 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9783
by: Sam | last post by:
Please help! I want to create a user control that can act as a container for other controls (like a panel or a groupbox). The control will consist of a panel that acts as the container for external controls plus some other stuff. I hoped that all I needed to do would be to implement System.ComponentModel.IContainer,
2
2148
by: Joe | last post by:
Hello all, When I drop a control (say a Button) on my user control, the button is added to the parent control of my user control and not my control. For example if my user control is on a panel and a drop a button on it, the button is added to the panel.Controls. I tried Bring to Front but it didn't make a difference. What am I doing wrong?
1
2593
by: Mike TI | last post by:
April 20, 2006 Hi All Is there a way I can tell the name of the user control docked in a Split Container Panel. I am using VB.Net 2005. e.g. if I dock a user control using the code below: UserControl1.Parent=Form1.SplitContainer1.Panel2
9
2430
by: timnels | last post by:
I have an issue where I have a user control that is launched into a floating form. At some point later, I allow the user to "unfloat" the user control by reparenting it on a split container in another form. Problem is if I wake a tooltip when the window is floated, and then try the same thing when it is reparented, the app crashes with " Cannot access a disposed object.Object name: 'Form'. Presumably, this is a result of the tooltips...
0
1250
by: alwayssmiling | last post by:
Hi, In my application, In the main form tab control is there. For this im adding a tabpage which contains a user control, this usercontrol contains many windows controls and other userdefined controls. In this Usercontrol a panel is there, which is a parent control for all reamaining controls. In this panel, a splitter control is there, in this splitter control left side i have another panel. In order to resize the controls based on the...
6
4722
by: Ronald S. Cook | last post by:
We have a Windows app that has one main form (a shell, sort of). We then load user controls into a panel on the form depending on what the user has selected. Our current code to unload the existing user control and load the newly selected one is pretty bulky. Every time we add a new user control to the project, we have to add some code in the section where we are loading/unloading. Is there a more dynamic, more efficient way to...
3
2000
by: Ronald S. Cook | last post by:
I lost my last post, but I'm looking for a better way to manage loading user controls (that are essentially forms) in a Windows app. In my current design, I have a ListBar in which the user selects an item. I then call a sub to loop through and remove any user control that may exist in the panel. But then I have a wordy select statement to load up the user control selected. Isn't there a better way?
7
6656
by: RichB | last post by:
I am trying to get to grips with the asp.net ajaxcontrol toolkit, and am trying to add a tabbed control to the page. I have no problems within the aspx file, and can dynamically manipulate a tabcontainer which has 1 panel already, however I want to try create the TabPanels dynamically. I followed the advice here: http://www.asp.net/learn/ajax-videos/video-156.aspx (3rd comment - Joe Stagner)
4
8407
hemantbasva
by: hemantbasva | last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even onactivetabindexchanged we have called a method loadtabpanel() which is defined in javascript in same page.the problem is it sometime give the message load tab panel undefined. this error does not come regularly. it comes in usercontrol rendering . i...
0
8674
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7721
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4615
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.