Visual Studio .NET forgets WindowState of base-class Form
-
VS.NET bug: In Visual Studio, if you have one Form which has its WindowState property set to "Maximized", and you then derive a second Form from that first one, the derived Form does not correctly inherit the WindowState from its parent. It will often end up with a WindowState of "Normal". The same may be true of the "Minimized" state; I haven't tried it. Repro steps: 1. Create new project: C#, type "Windows Application", any name. 2. Form1 is now open. In the Properties pane, set WindowState to "Maximized". 3. Build and run the program. The window is maximized, as it should be. 4. Select "Project > Add Windows Form..." from the menus. In the right pane (Templates), select "Inherited Form." Leave the name as "Form2.cs". Click Open. When the "Inheritance Picker" dialog comes up, select "Form1" as the base class. 5. Notice that over in the Properties pane, the WindowState for Form1 is "Normal", not "Maximized"! Oops. 6. Open Form1.cs, and in the Main() function, change "new Form1()" to read "new Form2()", so that Form2 is the one that will be launched by the program. 7. Run the program. Despite the fact that the Properties pane said "Normal", the program is in fact maximized. Oops. 8. Open Form2 in the Designer. Drop a button on it. Doing this will force Visual Studio to re-generate the Form2.InitializeComponent() function. 9. Run the program again. Now, notice that it is NOT maximized! Oops. You'll find that you can manually change WindowState back to "Maximized", but then, from time to time (I think mainly when you reload the project), Visual Studio will switch it back to Normal. Mike Morearty mike@morearty.com http://www.morearty.com