6

Using the WinForms WebBrowser control in edit mode (as described here), I am experiencing unnecessary scrollbars when switching the control into "IE9 mode".

I'm using the meta tag

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

as described in this posting to switch into editing mode.

This is how it looks like when being in "IE9 mode":

enter image description here

In contrast, when using it without the above meta tag, it correctly looks like this:

enter image description here

Here, it looks as expected; the horizontal scrollbar is not present at all and the vertical scrollbar is not active.

I tried every DOCTYPE I can think of; the result seems to stay the same.

(In case it matters: The content that is being switched into edit mode comes from a local HTTP URL of the built-in mini webserver of my application, i.e. not from a string or from a file URL).

My question is:

Is there a way to use the WebBrowser control with IE9 in "IE9 edit mode" and still have the scrollbars only when necessary?

Community
  • 1
  • 1
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291

1 Answers1

6

The scrollbars in the Web Browser control is determined by the document scroll settings and you can use the overFlow style to turn it off.

The following code works for me in preventing any scrollbars to appear:

    private void button1_Click(object sender, EventArgs e)
    {
        dynamic doc = this.Browser.Document.DomDocument;
        dynamic body = this.Browser.Document.Body;
        body.DomElement.contentEditable = true;

        doc.documentElement.style.overflow = "hidden";
    }
Rick Strahl
  • 17,302
  • 14
  • 89
  • 134