473,395 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

add different user controls in main form panel

i have main form which has one panel
i have two user controls uc1 and uc2
i am able to add uc1 in that panel
the problem is that i want to add fuctionality when i call my uc2 by clicking button present in uc1
so because of what my uc1 will hide n uc2 will appear at the same panel
Dec 9 '18 #1
2 2236
Luuk
1,047 Expert 1GB
I do not understand your question much further than following response:

Expand|Select|Wrap|Line Numbers
  1. IF uc1.Text='Show uc2' THEN uc2.Visible=true ELSE c2.Visible=false
Does this help? if not please give some more info.
Dec 14 '18 #2
I couldn't understand a lot but based on what I understood I am going to give u suggestion -

If you really want to do so you can write your code like this:

Expand|Select|Wrap|Line Numbers
  1. public static void showUC(Control uc, Control pnlContainer)
  2. {
  3.     pnlContainer.Controls.Clear();
  4.     uc.Dock = DockStyle.Fill;
  5.     pnlContainer.Controls.Add(uc);
  6. }
  7.  
and call it like this:

Expand|Select|Wrap|Line Numbers
  1. showUC(new someControlType(), someControlContainer);
No need to call the GC; do leave it to the system to clean up matters!

And a static function needs to know all objects it is supposed to work with, so you need to pass in the container as well.

Finally new needs paranthesis with (optionally) parameters..

I made the signature of the new control Control so you can pass in any control; and for even more flexibility the container is also Control. Note that this still allows you to pass in the Form! Of course you may want to go back to more restricted types..
Dec 16 '18 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David | last post by:
Hi, I have a page that will need to dynamically use 4 different user controls based on a Query String passed to it. Currently I have the @Register for each control and the <tagprefix: tagname> in...
1
by: CaymanVisitor | last post by:
Hi, I have a situation where I need to iterate through a forms controls collection and I need to do special processing on any control that is a user control. At run-time I won't know the names...
2
by: OpticTygre | last post by:
I have a treeview and a panel inside of a form. Depending on what item in the treeview is clicked, different user controls get loaded into the panel. If the form is resized, or maximized the panel...
8
by: MattB | last post by:
I have a asp.net 1.1/vb application that has a page with a bunch of dynamically added User Controls. When I add the controls, I set the UserControl.EnableViewState to true. For all my controls...
1
by: Alex Maghen | last post by:
Let's say I have a page which contains a bunch of text boxes and a Button. Then, also on the same page, I have a User Control I've created which has two text boxes and a button of its own. ...
1
by: Ufit | last post by:
Asume I have panel on a webform and I created few user controls (.ascx) How do I programaticaly add my user controls to that panel so it displays them as some sort of controls list? I've tried...
6
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...
3
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...
3
by: Ronald S. Cook | last post by:
I'm developing a Windows application that will have an ListBar like in Outlook. When the user clicks on a ListBar item, I would like to load the associated User Control. The below code works...
1
by: Valrossen | last post by:
Hi! I have a webpage with one form and multiple user controls. I want to create one (or more) object on Page_Init(), and use/modify this object in one or more usercontrols. How can i do...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.