Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying stylesheets to a desktop applications

Status
Not open for further replies.

varshan09

Programmer
Oct 28, 2003
45
0
0
IN
Hi All,
We have a requirement to change colour of all buttons and controls on the form throughout the application. I know we can easily do this in the web applications using stylesheets. Is there anything similar to stylesheets in desktop applications which can be used to change te colour of the controls in all forms throughout the application.

Can anybody suggest?

Thanks
Varsha
 
Tell they user to change their machines settings ;)

By default, all of the GUI Colors are based off of the System colors. So what ever they have their system colors set to is what color your form will be.

I'm not sure if colors can be effected like fonts/text through region settings, but it'd be something to look into.

-Rick

----------------------
[banghead]If you're about to post an ASP.Net question,
please don't do it in the VB.Net forum[banghead]

[monkey] I believe in killer coding ninja monkeys.[monkey]
 
About a third of the way down this article, you will find they are using advanced databinding. It does require some code.
However, if you are having your Tag properties free for all of your controls, there would be an easier way:

1. Use your tag property similar to css elements. For example, set it to "BGButtons", "Forms", "Panels", etc.
2. Create an xml file that you read into a collection.
3. The xml file will have different attributes such as BGButtons, Forms, Panels, etc. These will correspond to the tag strings you are using.
4. Key the collection with the attribute's names. For example, you can add a value to your collection based off the xml file using Color.FromName("StringValueFromYourXML"). You set it's key to "BGButtons", "Forms",etc.
5. Create a recursive routine that will check the tags of your controls and set the backcolors based on the collections.

You can even give the user a screen to change the values in the XML file. When the value changes, your XML loading and color setting routine runs again, and the colors change.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top