Application wide color and font settings?

  • Thread starter Thread starter Steve
  • Start date Start date
S

Steve

I am finding that I'm adjusting the colors and font sizes on all my controls
to achieve the look that I want. Without getting into the topic of whether
or not this is a good idea, is there a way to change the default colors for
all controls at the application level? (IE: I drag a label control onto a
form and it's next is the shade of grey that I want?)

I know I can change the windows system colors and this will effect my app as
well, but I would like to just change the colors in my app.

I thought about adding entries in the ApplicationSettings then initializing
all my controls to that value, but that requires me to add code for each
control and creates a maintenance issue (deleting a control from the
designer will produce unknown types in my constructors, etc)

Maybe someone has some other tricks for me? Is there something built in?

Thanks!
 
Steve,

If you don't set the control's background color for example explicitly it
uses the color of its container. If the container's color is not set it uses
its container color and so on and so forth. The same goes for fonts. That
means if you set the form's color and font only all the control on the form
will have the same background color as the form and use the same font.

Is this what you are after?
 
Hi Stoitcho,

I think that what he is really after is "How to change the settings for
all forms in an Application". (though I may be wrong, of course.)

Do you know of any way to do that ?

Regards,

Cerebrus.
 
Hi Stoitcho,

I was thinking too hard about this issue, I didn't see the obvious! :)

So if all my UI is UserControls hosted in a single panel in a Form, I can
just set the form properties. That will work well. I was also going to use
ApplicationSettings to store the color and "LookAndFeel" values.

Thanks for cluing me in.
Have a great weekend,
Steve
 
Cereberus,

Control class has static proeprties for default colors, fonts, etc.
Unfortunately they cannot be changed because they are readonly and simply
return the SystemColors values.

I don't know of any simple solution. In unmanaged application one can use
windows hooks for that. In windows forms only the form's properties needs
to be altered, so I would do some fromfactory and use it whenever I need to
create a form. The factory will set the properties upon creation.
 
Thanks Stoitcho,

I'll have to check out what a FormFactory is !!

Regards,

Cerebrus.
 
FormFactory would be a class that I'd write.
it will have one static method CreateForm for example. Having this factory
instead creating forms using the *new* operator MyForm f = new MyForm(), I'd
call MyForm f = (MyForm)FormFactory.CreateForm(....);
In CreateForm I'm going to create the form and set all the default values
for the properties. The CreateForm method should except some parameter (such
a Type object) that specifies the type of the form that needs to be created.
It could be also a value from some predefined enumberation of form types.
 
My ! That sounds like a really cool idea. Would really save a lot of
time.

Thanks for the reply,

Regards,

Cerebrus.
 
Back
Top