Forum Discussion
Windows form app incomplete Full screen
I have a C# forms app, and I want to provide full screen capability. I am using the follwing code
this.WindowState = FormWindowState.Normal; // apparently a good things to do
this.TopMost = true; // Keep the form on top
this.FormBorderStyle = FormBorderStyle.None; // Remove borders
this.WindowState = FormWindowState.Maximized; // Maximize the form
this maximizes to full screen okay, but I have a ToolStrip that refuses to go away. I tried this, to no avail:
this.MainToolStrip.Visible = false; // Hide the menu strip (does not work!)
Does anyone have any suggestions how go the final mile?
Thanks
Chuck Puckett, Esq., BS, ~MS, ThD
http://www.puckettpublishing.com/
"The unexamined life is not worth living." (Socrates)
"The unexamined faith is not worth believing." (Chuck)
"Anger is a wind that blows out the lamp of the mind." (Arabian proverb)
"Against stupidity, the gods themselves strive in vain" (Schiller)
"I don't want to steal the show... I only want to borrow it for a while." (Chuck)
1 Reply
Your form is already filling the screen; the remaining ToolStrip is a child-control visibility issue. TopMost only changes the form’s position relative to other windows, and removing the border does not hide controls inside it. MainToolStrip.Visible = false is the appropriate property for hiding that ToolStrip, provided it is the instance actually displayed. Put a breakpoint on that statement and inspect MainToolStrip.Name, Parent and Visible after it executes. Ensure the statement runs after InitializeComponent, rather than being overwritten by designer initialization. As a diagnostic, apply it from the form’s Shown handler, when the form is first displayed, and check whether later application code makes the control visible again. If the named control is hidden but a bar remains, identify that visible control in the debugger instead of changing the window state further. A minimal example showing where this code runs would distinguish those cases.