Solved

Can I make a UserControl static?

Posted on 2008-10-13
6
886 Views
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,

Steve
0
Comment
Question by:wsprhino
  • 3
  • 3
6 Comments
 
LVL 14

Accepted Solution

by:
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.

BR,
R
0
 

Author Comment

by:wsprhino
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.

Steve
0
 
LVL 14

Expert Comment

by:Ramuncikas
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?

R
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:wsprhino
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.
0
 
LVL 14

Expert Comment

by:Ramuncikas
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.

R
0
 

Author Comment

by:wsprhino
ID: 22715873

Thanks, I will give it a try
Steve
0

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

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 (http://www.microsoft.com/en-us/download/details.aspx?id=27876) 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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

828 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