Suppress WaitCursor for WinForms Office WebBrowser

Consider the following simple WinForms form with a text box and a web browser control. Whenever the contents of a text field change, the text is transferred to the browser:

public class MainForm : Form
{
    public MainForm()
    {
        var browser = new WebBrowser() { Dock = DockStyle.Fill };
        var textbox = new TextBox() { Dock = DockStyle.Fill, Multiline = true };
        var splitter = new SplitContainer() { Dock = DockStyle.Fill };

        splitter.Panel1.Controls.Add(textbox);
        splitter.Panel2.Controls.Add(browser);
        this.Controls.Add(splitter);

        textbox.TextChanged += delegate { browser.DocumentText = textbox.Text; };
        textbox.Text = "<b>hello world</b>";
    }
}

(I do something similar in my DownMarker to create a Markdown editor using the Stackoverflow MarkdownSharp library.)

This works great, except that the control WebBrowserinsists on showing the wait cursor whenever it is DocumentTextinstalled, even if updating the contents of the browser takes only a few milliseconds. This causes the mouse cursor to flicker when entering a text field.

? DocumentText, , , .

</" > edit: . TextChanged , , :

textbox.TextChanged += 
    delegate 
    {
        if (browser.Document == null)
        {
            browser.DocumentText = "<html><body></body></html>";
        }
        while ((browser.Document == null) 
            || (browser.Document.Body == null))
        {
            Application.DoEvents();
        }
        browser.Document.Body.InnerHtml = textbox.Text;
    };

edit2: , , . . , html, , , , .

+3
1

DocumentText - , WebBrowser . . , , , .

DOM Document. -, Ajax javascript, - . . , , , HTML- <body> .

. - ! . , , HTML.

+5

Source: https://habr.com/ru/post/1777348/


All Articles