Set same icon for all my Forms

.net, c#, icons, winforms

Solution

One option would be to inherit from a common base-Form that sets the Icon in the constructor (presumably from a resx). Another option might be PostSharp - it seems like it should be possible to do this (set .Icon) via AOP; not trivial, though. Finally, you could use a simple utility method (perhaps an extension method) to do the same.

Best of all, with the first option, you could probably risk a Ctrl+H (replace all) from `: Form` or `: System.Windows.Forms.Form` to `: MyCustomForm`.

Problem

Is there any way to set the same icon to all my forms without having to change one by one? Something like when you setup `GlobalAssemblyInfo` for all your projects inside your solution.

Original source