Make UserControl fullscreen

2019-08-12 07:54发布

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.

3条回答
\"骚年 ilove
2楼-- · 2019-08-12 08:15

Temporarily move the control to a new borderless form and make that form full screen.

查看更多
Fickle 薄情
3楼-- · 2019-08-12 08:22

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();
}
查看更多
做个烂人
4楼-- · 2019-08-12 08:36

You can make a temporary window from within the usercontrol to provide fullscreen.

查看更多
登录 后发表回答