C#在设计器模式下隐藏窗体中的控件

时间:2022-02-18 14:46:59

I currently have a webBrowser that takes up full screen but when a user clicks on a certain button, the webBrowser hides and the the user is able to see the items behind the webBrowser.

我目前有一个占全屏的webBrowser,但当用户点击某个按钮时,webBrowser会隐藏,并且用户可以看到webBrowser背后的项目。

How can I make it so that I am able to see the items behind the webBrowser without actually hiding the webBrowser or sending it to back in the designer.

我怎样才能使它能够在不实际隐藏webBrowser或将其发送回设计器中的情况下看到webBrowser背后的项目。

For example, is there a way to right click and make invisible a form only during designer mode?

例如,有没有办法在设计师模式下右键单击并使表单不可见?

2 个解决方案

#1


Every WebBrowser inherits from System.ComponentModel.Component. Components have readonly field DesignMode which states if current component is in design mode.

每个WebBrowser都继承自System.ComponentModel.Component。组件具有只读字段DesignMode,其指示当前组件是否处于设计模式。

You can use it e.g. this way (I don't see Your code so I am imaging). Just be sure to add this code in Your designer class

你可以使用它,例如这样(我没有看到你的代码,所以我成像)。请务必在您的设计器类中添加此代码

if (webBrowser.DesignMode)
{
    webBrowser.Visible = false;
}

WebBrowser Class

https://msdn.microsoft.com/en-gb/library/system.windows.forms.webbrowser(v=vs.110).aspx

Component.DesignMode Property

https://msdn.microsoft.com/en-gb/library/system.componentmodel.component.designmode(v=vs.110).aspx

#2


The easy way is to design the WebBrowser control with a very small size, and blow it up to full screen on the form's constructor right after the InitializeControls() call is completed.

简单的方法是设计一个非常小的WebBrowser控件,并在InitializeControls()调用完成后立即在窗体的构造函数上将其全屏展开。

#1


Every WebBrowser inherits from System.ComponentModel.Component. Components have readonly field DesignMode which states if current component is in design mode.

每个WebBrowser都继承自System.ComponentModel.Component。组件具有只读字段DesignMode,其指示当前组件是否处于设计模式。

You can use it e.g. this way (I don't see Your code so I am imaging). Just be sure to add this code in Your designer class

你可以使用它,例如这样(我没有看到你的代码,所以我成像)。请务必在您的设计器类中添加此代码

if (webBrowser.DesignMode)
{
    webBrowser.Visible = false;
}

WebBrowser Class

https://msdn.microsoft.com/en-gb/library/system.windows.forms.webbrowser(v=vs.110).aspx

Component.DesignMode Property

https://msdn.microsoft.com/en-gb/library/system.componentmodel.component.designmode(v=vs.110).aspx

#2


The easy way is to design the WebBrowser control with a very small size, and blow it up to full screen on the form's constructor right after the InitializeControls() call is completed.

简单的方法是设计一个非常小的WebBrowser控件,并在InitializeControls()调用完成后立即在窗体的构造函数上将其全屏展开。