Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make UserControl fullscreen

I'm developing a reusable UserControl that among other features should provide a full screen mode.

But how to accomplish this?

Typically, the container form should be maximized, not the UserControl.

Is there any way to force a UserControl to temporary occupy the entire screen?

I understand this is not something that should be normally done, but I have reasons to make it this way.

like image 924
SharpAffair Avatar asked Jul 02 '26 18:07

SharpAffair


1 Answers

You should be able to re-use the control by removing it from it's container, and then create a full screen, borderless form.

private void OnGoFullScreenMode()
{
     this.Controls.Remove(goLiveControl);
     this.ShowFullScreen(goLiveControl);
}

private void ShowFullScreen(UserControl userControl)
{
     Form fullScreenForm = new Form();
     fullScreenForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
     fullScreenForm.WindowState = FormWindowState.Maximized;
     fullScreenForm.ShowInTaskbar = false;
     userControl.Dock = DockStyle.Fill;
     fullScreenForm.Controls.Add(userControl);            
     fullScreenForm.Show();
}
like image 189
Steve Wong Avatar answered Jul 04 '26 06:07

Steve Wong