I am using Microsoft Visual Studio creating a Windows Form Application (Small Puzzle Game). I don’t know how I should add my User Controls to my Form. I have seen many examples on how you can do it, but I am yet to find an answer that takes performance into account, atleast that’s what I believe.
Here are the two methods that I have used:
- UserControl.Visible = True / False
One of the more common methods that I have seen is to place your User Control in your Form and setting the visibility to False. Whenever the User Control needs to be visible you simply set Visible to True. I personally feel that this is a very bad way to handling User Controls. This can become very disorienting when you have a lot of controls in your Form. This is the method I was taught to use.
- Load User Control “Dynamically”
Loading a User Control dynamically implies that I add the User Control to a container (Panel, etc.)
The code can look something like this:
Public Class Form_Main ' Instance User Control Public Shared UC_Main As New UserControl_Main ' On Form Load Private Sub Form_Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load ' Add Main Menu Control Panel_Container.Controls.Add(UC_Main) End Sub End Class
The question about Performance and Method
What methods of adding and disposing User Controls are most efficient in terms of performance?
Here is an example of what I am trying to do and my issue:
I have an option menu with 5 buttons, all of which adds a new User Control to the form (Using method 2). I use the
Control.ControlCollection.Remove Method to remove a control whenever want to go back to the options menu again. Whenever I then start the game I dispose all unnecessary User Controls to save performance. The problem is that I have to re-instance all User Controls whenever I want the user to go back to the options menu.
I am aware that windows forms are not created for Game-Development in any way.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!