Reputation: 7900
I have WebBrowser
control in my Form
. and i allow JavaScript
that call a method in the C# form :
[ComVisible(true)]
public class ScriptManager
{
// Variable to store the form of type Form1.
private Form1 mForm;
// Constructor.
public ScriptManager(Form1 form)
{
// Save the form so it can be referenced later.
mForm = form;
}
// This method can be called from JavaScript.
public void EnterFullScreenMode()
{
// Call a method on the form.
mForm.EnterFullScreenMode();
}
}
And in the form i include this method :
public void EnterFullScreenMode()
{
browser.ScrollBarsEnabled = false;
}
And i noticed that when i call this method to remove the scroll bar of the WebBrowser
the page is refresh and the scroll bar still there.
Any idea what is the issue? There is any other way to hide and disable scrolllbar?
Upvotes: 1
Views: 4980
Reputation: 61666
Internally, browser.ScrollBarsEnabled
is provisioned as DOCHOSTUIFLAG_SCROLL_NO flag via IDocHostUIHandler::GetHostInfo. The WebBrowser
object has to reload the document for the new value to be picked up.
I'd suggest setting browser.ScrollBarsEnabled
to false
for once, after InitializeComponent()
in your form, then control the scrolling with CSS: <body style="overflow: auto">...</body>
will make scrollbars automatic, and style="overflow: hidden"
will make them disappear.
Upvotes: 3