Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Can I make a UserControl static?

Posted on 2008-10-13
6
Medium Priority
?
920 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
[X]
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
6 Comments
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 600 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
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 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