Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Visual Studio .NET forgets WindowState of base-class Form

Visual Studio .NET forgets WindowState of base-class Form

Scheduled Pinned Locked Moved C#
csharpvisual-studiowpfcomoop
1 Posts 1 Posters 5 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Morearty
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups