Can I make a UserControl static?

Posted on 2008-10-13
Last Modified: 2013-12-17
I have a user control, just a collection of buttons and combo boxes really. The UserControl can appear on multiple other forms and panels and it would be good to keep them all in synch. The easiest way to do this it seems is to make the the usercontrol static  but I am not sure.

Is this the way to go? Will I have problems just marking the control as static or will VS designer have problems make the conversion? Or, is there a better way to do this. All the forms and usercontrols on which thecontrol appears report back to the same main form.

Thanks for any ideas,

Question by:wsprhino
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
LVL 14

Accepted Solution

Ramuncikas earned 200 total points
ID: 22704256
There is no way to make control static for various reasons. But this "simulation" could be easily implemented.

One way would be to create class that would be a kind of datasource for your control and put is into session. All your controls could reference the same class in session and then set all changes back to it. Then control of the same type on the other page could get all data from this class with changes made in previous page.

If you give some more info about what you're up to or ask some more specific questions then we could be more helpful.


Author Comment

ID: 22704678

The application I have has about 5 applications each with its own form.
  Each application form consists of a tool strip a viewbox for generating pictures, and a panel for allowing the user to modify what he sees.

Each application has various input data that can generally be grouped into categories. E.g. fill color for the different shapes and color, style to draw the edges of the shapes. Some of these are common to more than one of the applications. All this data fits on the panel grouped into regions.The panel can be hidden.

Also, the toolstrip has buttons which allows a form to be popped up for each of the input 'sub panels' of the input panel. For some of the applications the application may be too large for a small screen. So, thie  toolstrip buttons are an alternative way of input.

I have created the subpanels as controls but when these are placed on the input panel and the pop up forms I want them to always to be in synch.

Another reason for wanting common code is that some of the panels have a lot of buttons used for entering colors. Each of the ColorButtons when clicked pops up a tabbed pane for choosing a color somewhat similar to what VS has in its Property panel for choosing a color. Each of these buttons at the moment contains  a list of all the colors available or created by the user. This is a lot of duplication when each 'application' can have up to 20 ColorButtons and the only difference between them is the sort order of the colors.
At the moment the main form has control and receives notification when something has changed on one of the sub panels. It is responsible for informing the PopUpForm or InputPanel that something has changed on the other.

I just feel there should be a better way to do this that allows synching to be done automatically. Because if I change the contents of a subpanel the ApplicationForm needs to know to tell the InputPanel or the PopUp what has changed.

Also my list of colors is large and doesn't just consist of simple colors. Currently around 400 of them.

Hope this gives you a general idea of what I am trying to do and why.

LVL 14

Expert Comment

ID: 22708848
"The application I have has about 5 applications each with its own form"

Could you please explain me this? Is it 5 different .exe files or just one single applications with 5 different forms?

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.


Author Comment

ID: 22709108

looking back the 5 applications are actually 5 UserControls that all have the same layout and so appear to overlay each other exactly. There is only one exe and one main form. Sorry, that was a mistake. But, ultimately there will be many more 'applications'. Some will be very similar while others will be quite different. But, they will all have the same general layout : a toolstrip, a viewbox and an input panel, plus the various mini-input panels that can be launched from the toostrip.
LVL 14

Expert Comment

ID: 22714001
So more or less solution could be the same. Define some static class to store settings for each of your control. Each control changes settings in that class upon user interaction. In other form other control of the same type could bind to same static class.

In short your controls would be instances but their datasource would be static class what would make it look like the same control instance is used all over application.


Author Comment

ID: 22715873

Thanks, I will give it a try

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to Office 1 66
Web page design problem 3 41
How does this modal gets closed? 6 41
function that i need to run every 1 min in win form app 6 38
A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below.…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question