Make UserControl fullscreen

僤鯓⒐⒋嵵緔 提交于 2020-01-05 08:48:13

问题


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.


回答1:


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




回答2:


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();
}



回答3:


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



来源:https://stackoverflow.com/questions/10128008/make-usercontrol-fullscreen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!