Subject: Theme/skin win forms controls
Posted By: planoie Post Date: 8/21/2008 12:39:33 PM
My apologies for posting in what really is the generic .NET 2.0 framework forum, but frankly the Winforms forum doesn't seem to get much use or exposure.

Short question: How do I skin or theme windows forms controls?

I am starting a project to revamp an existing windows desktop application.  We have decided to do a complete re-write (with liberal cut-'n-pasting) of the app from it's original .NET 1.1 version, into .NET 2.0 (not more than 2.0 for older platform support).  I am looking into ways of expediting development by eliminating the overhead of manual styling of all the form's controls.  I have googled a bit and found that control themes and skins are supported in 3.5, but of course that doesn't help me.  2.0  doesn't appear to have that functionality.  I have found some samples (CodeProject and the like) that offer some solutions, but I wanted to get the p2p community's ideas and/or suggestions about the topic.

-Peter
compiledthoughts.com
Reply By: gbianchi Reply Date: 8/21/2008 1:03:05 PM
Hi Peter..

I did something similar in 2.0. You can store in the config file colors, fonts and other things that let you personalize the controls. All you have to do is in everycontrol bound the corresponding property to the config file (and of course "field") and you are almost "skining" it. If you need more help I have the sample code of the form that let you personalize everything.

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================
Reply By: planoie Reply Date: 8/21/2008 4:05:56 PM
Gonzalo, thanks for the reply.  So this solution requires that you set up data binding on each control, correct?  Part of what I'm hoping to achieve is a solution that doesn't require a developer to touch every control in the form, essentially what skins let you do in ASP.NET: define a default style for each control type.  Granted, by binding style properties to something I could abstract away the details of the styles to a central configuration, but I'm still left with the problem of having to bind each control.  Perhaps I'll use the method of super classing my forms and controls so that standard styles can be applied to all child controls centrally.  Of course, this still requires adjusting the class the forms and controls derive from.  Same problem, just in a different place.  Although, that would probably also eliminate the multiple bindings required for styles.

-Peter
compiledthoughts.com
Reply By: gbianchi Reply Date: 8/21/2008 4:28:21 PM
You can always build a control that is binding to the config file, and inherits always from it ;)

HTH

Gonzalo

===========================================================
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
===========================================================
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
===========================================================
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles/Classics-Week-I-Hate-You.aspx
===========================================================

Go to topic 73584

Return to index page 1