0

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.

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.

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

H H
  • 263,252
  • 30
  • 330
  • 514
DanMossa
  • 994
  • 2
  • 17
  • 48
  • possible duplicate of [Hide WPF elements in Visual Studio designer](http://stackoverflow.com/questions/1322520/hide-wpf-elements-in-visual-studio-designer) – molnarm May 03 '15 at 09:53
  • Context menu (Right mouse click) `Send to back` in WinForms designer – Ilia Maskov May 03 '15 at 10:21
  • 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 – Zohar Peled May 03 '15 at 10:32
  • Another possibility would be to change your program design so the WebBrowser is on a separate form/window that gets launched when it is needed. – RenniePet May 03 '15 at 11:16
  • @ZoharPeled, I'm gonna go with your answer! Feel free to post it as a legit answer and I'll checkmark it – DanMossa May 03 '15 at 21:53
  • possible duplicate of [Detecting design mode from a Control's constructor](http://stackoverflow.com/questions/1166226/detecting-design-mode-from-a-controls-constructor) – vesan May 04 '15 at 04:17

2 Answers2

0

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

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

myś
  • 94
  • 1
  • 5
0

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.

Zohar Peled
  • 79,642
  • 10
  • 69
  • 121