473,563 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need more efficient way to load/unload user controls on form

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 manage user controls loading
in a form?

Any help would be appreciated.

Thanks,
Ron
Feb 14 '07 #1
6 4709
I would use VB.

VB is obviously more efficient than CSharp

I mean; CSharp has only been around for a couple of years now; it's
basically still in beta

On Feb 13, 7:24 pm, "Ronald S. Cook" <r...@westinis. comwrote:
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 manage user controls loading
in a form?

Any help would be appreciated.

Thanks,
Ron

Feb 14 '07 #2
That's not true.

Robin S.
-----------------------------------
<aa*********@gm ail.comwrote in message
news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
>I would use VB.

VB is obviously more efficient than CSharp

I mean; CSharp has only been around for a couple of years now; it's
basically still in beta

On Feb 13, 7:24 pm, "Ronald S. Cook" <r...@westinis. comwrote:
>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 manage user controls
loading
in a form?

Any help would be appreciated.

Thanks,
Ron


Feb 14 '07 #3
Hi Ronald,

There are different ways to do this. One way is to treat your user controls
as plugins. Example would be that all your controls implement an interface
which would have Load(...) and Unload(...) methods. Then you would have a
control container for each option which would contain the user controls for
that option. And finally when ever a user selects an option then the form
would call Controlcontaine r's Display() method (Check the code below)

some pseudo-code:

public interface IControlPlugin
{
void Load(...);
void Unload(...);
}
public class MyControl : UserControl, IControlPlugin
{
...
public void Load(...)
{
...
}

public void Unload(...)
{
...
}
}
public class ControlContaine r : UserControl
{
private List<UserContro lmControls;

public void Add(UserControl control)
{
if(control is IControlPlugin)
mControls.Add(c ontrol);
else
throw new Exception("Inte rface not implemented");
}

public void DisplayControls (Control parent)
{
foreach(UserCon trol ctrl in mControls)
{
IControlPlugin plugin = ctrl as IControlPlugin;
ctrl.Load();
parent.Controls .Add(ctrl);
ctrl.Parent = this;
}
}

public void UnloadControls( Control parent)
{
foreach(UserCon trol ctrl in mControls)
{
IControlPlugin plugin = ctrl as IControlPlugin;
ctrl.Unload();
parent.Controls .Remove(ctrl);
ctrl.Parent = null;
ctrl.Dispose();
}
}
}
Hope this helps
Fitim Skenderi

"Ronald S. Cook" <rc***@westinis .comwrote in message
news:%2******** **********@TK2M SFTNGP06.phx.gb l...
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 manage user controls
loading in a form?

Any help would be appreciated.

Thanks,
Ron


Feb 14 '07 #4
why is it not true?

C sharp is still in beta; I mean; it's only been around for a couple
of years

it's sort of like 'dont ever buy windows until sp1 comes out'

except csharp needs about FORTY FUCKING YEARS TO CATCH UP TO VB


On Feb 14, 12:31 am, "RobinS" <Rob...@NoSpam. yah.nonewrote:
That's not true.

Robin S.
-----------------------------------<aaron.ke...@gm ail.comwrote in message

news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
I would use VB.
VB is obviously more efficient than CSharp
I mean; CSharp has only been around for a couple of years now; it's
basically still in beta
On Feb 13, 7:24 pm, "Ronald S. Cook" <r...@westinis. comwrote:
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 manage user controls
loading
in a form?
Any help would be appreciated.
Thanks,
Ron- Hide quoted text -

- Show quoted text -

Feb 14 '07 #5
Thanks, I'll try that. Any other options?
"fitim skenderi" <fi****@hotmail .comwrote in message
news:O4******** ******@TK2MSFTN GP06.phx.gbl...
Hi Ronald,

There are different ways to do this. One way is to treat your user
controls as plugins. Example would be that all your controls implement an
interface which would have Load(...) and Unload(...) methods. Then you
would have a control container for each option which would contain the
user controls for that option. And finally when ever a user selects an
option then the form would call Controlcontaine r's Display() method (Check
the code below)

some pseudo-code:

public interface IControlPlugin
{
void Load(...);
void Unload(...);
}
public class MyControl : UserControl, IControlPlugin
{
...
public void Load(...)
{
...
}

public void Unload(...)
{
...
}
}
public class ControlContaine r : UserControl
{
private List<UserContro lmControls;

public void Add(UserControl control)
{
if(control is IControlPlugin)
mControls.Add(c ontrol);
else
throw new Exception("Inte rface not implemented");
}

public void DisplayControls (Control parent)
{
foreach(UserCon trol ctrl in mControls)
{
IControlPlugin plugin = ctrl as IControlPlugin;
ctrl.Load();
parent.Controls .Add(ctrl);
ctrl.Parent = this;
}
}

public void UnloadControls( Control parent)
{
foreach(UserCon trol ctrl in mControls)
{
IControlPlugin plugin = ctrl as IControlPlugin;
ctrl.Unload();
parent.Controls .Remove(ctrl);
ctrl.Parent = null;
ctrl.Dispose();
}
}
}
Hope this helps
Fitim Skenderi

"Ronald S. Cook" <rc***@westinis .comwrote in message
news:%2******** **********@TK2M SFTNGP06.phx.gb l...
>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 manage user controls
loading in a form?

Any help would be appreciated.

Thanks,
Ron



Feb 14 '07 #6
how is it not true?

c# was invented for no reason; because MS didn't understand or
appreciate the popularity of VB

that is the only reason
and now .NET is a 1/4 replacement for Vb6-- I can't use .NET in
ActiveX scripts; I can't use .NET in office or in VBS files


and I can't use vb.net or vbs on the clientside of a browser
IS THIS PROGRESS??
C@ On Feb 14, 12:31 am, "RobinS" <Rob...@NoSpam. yah.nonewrote:
That's not true.

Robin S.
-----------------------------------<aaron.ke...@gm ail.comwrote in message

news:11******** **************@ p10g2000cwp.goo glegroups.com.. .
I would use VB.
VB is obviously more efficient thanCSharp
I mean;CSharphas only been around for a couple of years now; it's
basically still in beta
On Feb 13, 7:24 pm, "Ronald S. Cook" <r...@westinis. comwrote:
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 manage user controls
loading
in a form?
Any help would be appreciated.
Thanks,
Ron- Hide quoted text -

- Show quoted text -

Feb 16 '07 #7

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

Similar topics

6
17053
by: Matthew Wells | last post by:
I am trying to load a form (load Me) without the form becoming visible. If I try me.hide or me.visible = false, they load the form and the form blinks before becoming invisible. Is there a way to load the form without it becoming visible at all until I say me.visible = true? Thanks. Matthew Wells MWells@NumberCruncher.com
19
4078
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can...
0
2503
by: Frank 'Olorin' Rizzi | last post by:
Hello everyone. This is quite convoluted, but I'll try to make it simple. I have a couple of bottom-line questions (I guess): 1~ what happens between the Page_Load routine in the code behind of an aspx page and the presentation of the page to the user? 2~ is it true that the engine takes data from the Request.Form and puts them
1
2021
by: seanmayhew | last post by:
I have a form page that that while editing saves the data to an xml doc before submitting to db. On each page unload it saves the xmldoc as the user can add multiple items to the company like product types etc. So for instance Im adding a fruit company while adding a fruit company I allow the user to add types of fruit they carry and...
4
2677
by: Gene | last post by:
As my purpose is to load one form at a time, so I want to unload another form before loading the form. But how to check which form is being load, so I can unload it first.
15
2271
by: carr4895 | last post by:
Hello. I was wondering if someone could help me too with a login form. Upon startup, I have to display a password screen and it should accept a user name and password. User name can be anything non-blank. If there is no user name, an appropriate error message must be displayed. All of the following passwords are valid IT160, VB2Manager,...
2
1485
by: mabzkie | last post by:
whats wrong with my codes? i need to login using two textfields: txtuser for the username and txtpass for the password. i am using ado and ms access as a database. when i tried to enter with a long password i always get these error "either bof or eof is true." and when i try to enter with a right password but with a wrong username, i successfully...
2
13577
by: Ronald S. Cook | last post by:
I have a Windows app with a split container (SplitContainer1) 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...
3
13597
by: sphinney | last post by:
Hello, All. I'm embarrassed to even ask this question because it seems like such a simple thing. But, here it is … What is the code to make a form unload itself? I have a form with a number of controls and buttons on it. When the user clicks the button ‘A’, I want the form to close itself. I’ve tried using the “Unload” statement,...
0
7664
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...
0
7583
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6250
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...
0
5213
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
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

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.