Winform Style Sheets?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

Is there a way to change the properties of certain controls on all forms
that a control exists on?

For instance, say I have 10 forms in a solution, and each has a datagrid. I
want to change the backgroundcolor of a datgrid and want this change to take
place on all the datagrids in the solution, is there a way to change it once,
and have it cascade to all the other datagrids?? Similar to a style sheet
with web pages...
Or do I have to change each one manually?

Thanks in advance,
 
WinForms offers visual inheritance which will allow you to accomplish what
you're looking for. I typically create a base application form, let's call
it AppBaseForm, that other forms in my application derive from. This allows
me to control, in one location, a standard application icon, for example.

You can derive other forms from your base form as well- so if your
accounting department, for example, has a custom look and feel or graphic you
could inherit from AppBaseForm and create another base form called
AcctBaseForm that all accounting screens could inherit from.

..Net is an extensible framework. You can be more granular than the form
level and derive from the DataGrid control and extend it (ie, customize
colors) by creating a custom user control that extends the datagrid by
inheriting from it and customizing it. This allows you to add your custom
control onto one or many forms and control behaviour in a single location.

JP
 
Back
Top