Windows Forms Stylesheets?

G

Guest

Is there anything equivalent to CSS for use in windows forms? I’d like to be
able to have the colors and fonts determined by some kind of configuration
file (ala Cascading Style Sheets) so that individual application users can
customize the user interface to there taste.

Is there any simple way to accomplish this? If not, does anyone have any
suggestions for methods or strategies to accomplish this?

Oh... by the way, I'm using Visual Studio 2003 & VB.NET but would happily
use Visual Studio 2005 if this functionality was built in.

Thanks,

Jonathan
 
D

Dave Sexton

Hi Jonathan,

Some of that functionality is already built into Windows: Right-click desktop --> Properties --> Appearance --> Advanced. Most
Windows users, I believe, would rather use their settings then yours.

As for layout, you might want to look into XAML (however I'm not sure if end users can make use of XAML but in most cases it
wouldn't be the best design anyway for a program to allow their users to redesign the interface as they see fit), but that won't be
available until Vista, AFAIK:
http://msdn.microsoft.com/windowsvista/prodinfo/what/about/default.aspx#wpfx

Otherwise, you'd have to code a custom system or look for third-party solutions.
 
C

Chris Dunaway

jlotmar said:
Is there anything equivalent to CSS for use in windows forms? I'd like to be
able to have the colors and fonts determined by some kind of configuration
file (ala Cascading Style Sheets) so that individual application users can
customize the user interface to there taste.

Is there any simple way to accomplish this? If not, does anyone have any
suggestions for methods or strategies to accomplish this?

Oh... by the way, I'm using Visual Studio 2003 & VB.NET but would happily
use Visual Studio 2005 if this functionality was built in.

It's not built in to VS2005, sadly. But as Dave pointed out, if you
use the standard system colors (e.g. Color.ActiveCaption, etc..) then
the users can configure your app using their Windows color scheme.
Otherwise you may have to "roll your own".

There are third party solutions. One I looked at before is called
IrisSkin. It seemed to be fairly simple to use. There are others as
well.
 
G

Guest

Yes, I thought about this but most of the users are very very very basic. If
we asked them to change the settings using windows, well... who knows.

On the other hand, given the design of the application, by simply changing
there preferences (a theme if you will) it should be more appealing to the
user. The other side is that if I could control the appearance (colors,
fonts, etc.) through a style sheet, then I could define the sheet in the
config file so that I could easily differentiate the application from one
user role to the next without having to add to much overhead in the
application.

I guess it's not that big of a deal since very few of the users even care
about it at this point, I just thought it might be a chance to get some
brownie points with the users. Thanks for the reply though. It'll give me
some food for thought.
 
D

Dave Sexton

Hi Jonathan,

Well, if your users don't know how to modify Windows appearance I don't see how it would be any easier to teach them to use a custom
solution. If they're not happy with the appearance of your program then you should find out what they dislike and change it,
wherever practical and possible. If they can't agree with each other on an acceptable solution then you might want to offer
multiple interfaces or interface components.

As for role-based changes to the UI, I agree that file-based configuration could be useful to an extent, but you'll still have to
write code to handle the display and business logic. You should also implement role-based security in code to prevent unwanted
access to your components, so "stylesheets" wouldn't be the whole story anyway. I handle that type of security on a
role-per-control basis in my software, usually, but for one client I've created a proprietary ToolStrip framework to merge/hide
buttons and menu items based on role associations defined in an xml file that is embedded into the main assembly. This also
required a custom command framework to be written, so this type of solution is not for every application.

You could also use the .NET 2.0 Providers framework to create configurable settings for certain aspects of the program. The
Providers framework has out-of-the-box support for membership and roles, configurable through the .config file of the executable,
and you can write your own Providers as well. Providers can be used for WinForms apps as well as ASP.NET.

Providers on MSDN:
http://msdn.microsoft.com/asp.net/downloads/providers/

If the end users of your program don't make a big deal of it then you probably shouldn't either. You might find that you'll earn
even more respect if you help to automate some of their more mundane and time-consuming operations and make it easier for them to
perform the tasks that can't be completely automated.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top