I have a .NET 3.5 MDI WinForms application.
I set a a child form's Icon
property, and the icon shows up correctly in the top left corner of the form. I then maximize the child form and the icon is still OK.
With the child form still maximized, I open another child window, which automatically comes up maximized. This form's icon is not the one in the Icon
property, but the default .NET icon (the one with the blue, red, and yellow squares). However, if I resize the MDI parent form, the icon resets itself and displays properly.
Does anyone have a workaround or know why this happens?
A slight modification to Calanus' solution:
private void MdiBase_Load(object sender, EventArgs e)
{
// Fixes bug where loading form maximised in MDI window shows incorrect icon.
this.Icon = Icon.Clone() as Icon;
}
This allows you to set the icon at design time (just as you would for other forms), and does not need any hard-coded file or resource accessing.