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 project
In additional to Marc's recommendation, you may want your forms to automatically inherit the icon of the executing assembly that contains/calls them.
This can be done by adding the following code to your inherited form:
public MyCustomForm()
{
Icon = GetExecutableIcon();
}
public Icon GetExecutableIcon()
{
IntPtr large;
IntPtr small;
ExtractIconEx(Application.ExecutablePath, 0, out large, out small, 1);
return Icon.FromHandle(small);
}
[DllImport("Shell32")]
public static extern int ExtractIconEx(
string sFile,
int iIndex,
out IntPtr piLargeVersion,
out IntPtr piSmallVersion,
int amountIcons);