views:

388

answers:

2

hi.

i have an application with main form. the main form has menu and some toolstrip and one usre control set the dock to Fill. how can i provide full screen view so that usre control set to full screen and all menu and tooltrips hide from main form.

A: 

I would programmatically change UI, hiding all container panels except the work-area container panel, where user control is located.

Andrew Florko
can u give me sample code. i have main menu and one toolstrip in main form
Mohsan
call Hide method on toolstrip and panels you want to free space on the form.
Andrew Florko
A: 

Not that I've ever done it - by my approach would be to:

In your full screen 'mode' do this:

switch off the form border set controlbox to false (gets rid of the titlebar and top-left window menu) make the menu/toolstrip invisible.

This is done with the 'Visible' property of those controls.

Now, you should be able to set the window state of the form to Maximized.

EDIT - Code Sample:

Paste this into the code file of a new forms app

public partial class Form1 : Form
{
  public Form1()
  {
    InitializeComponent();
  }
  private void Form1_Load(object sender, EventArgs e)
  {
    this.ControlBox = false;
    this.FormBorderStyle = FormBorderStyle.None;
    this.WindowState = FormWindowState.Maximized;
  }

  private void Form1_KeyDown(object sender, KeyEventArgs e)
  {
    //example of how to programmatically reverse the full-screen.
    //(You will have to add the event handler for KeyDown for this to work)
    //if you are using a Key event handler, then you should set the 
    //form's KeyPreview property to true so that it works when focus
    //is on a child control.
    if (e.KeyCode == Keys.Escape)
    {
      this.ControlBox = true;
      this.FormBorderStyle = FormBorderStyle.Sizable;
      this.WindowState = FormWindowState.Normal;
    }
  }
}
Andras Zoltan