How to keep DRY when I need to overload a method for all of my forms?

.net, c#, dry, winforms

Solution

What about a base class which inherits `Form` and overrides the whole `CreateParams` property. Then, the rest of concrete forms inherits your `CustomForm`.

Any form within your application will share this `CreateParams` implementation and, if some of them requires a specific implementation, an override in the concrete class will be enough! ;)

Problem

On all of my C# forms, I have the following code: ``` protected override CreateParams CreateParams { get { const int WS_EX_TOOLWINDOW = 0x80; CreateParams cp = base.CreateParams; cp.ExStyle |= WS_EX_TOOLWINDOW; return cp; } } ``` How would I remove this from each of my forms and keep my code clean?

Original source