-1

I have a Project with like 10 WinForms or so. Right now, the Form and its Controls are having a default style/Look. I want to build a class that can set/change the UI of each form.

I believe an Interface class should be developed and then should be Inherited to any form desired. I hope i am right on this. How would I do this?

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
911Rapid
  • 199
  • 3
  • 13
  • A bit vague a question... can you add some examples? And have you ever considered using WPF instead? Or break up the forms into multiple and reuseable custom user controls? – Florian Schmidinger Mar 18 '15 at 13:58
  • @FlorianSchmidinger : No, i cannot go with WPF. I should work with WinForms itself. I don't know what examples you need? I would like to know more about breaking the forms into multiple forms and making reusable custom controls. Thanks – 911Rapid Mar 18 '15 at 14:40
  • 1
    If you got a certain layout that repeats itsself ... i.e. labels and textboxes for entering an address, you could make a user control encapsulating these functions. Then you are able to use this control over and over again... another example would be data-navigation... its also possible to put this user control into extra librarys so that you also can use them for other projects... There are also derived User Controls and derived Forms that can manage layout in a polymorphic manner. – Florian Schmidinger Mar 18 '15 at 15:00
  • a good resource are youtube videos and/or videos from microsofts virtual academy. it would be too much to explain all these possibilities in text =) – Florian Schmidinger Mar 18 '15 at 15:04

1 Answers1

2

You can achieve this by creating a base class that derives from Form. You can set the styles inside that base class, and those will be derived by all classes deriving that base class. You can set Font, or BackColor for example.

I want to suggest to take a look at WPF, which has a much better model for this. WPF has the ability to decouple layout and the technical working of a Window. You can set styles that are applied automatically to all controls of a certain type.

Community
  • 1
  • 1
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325