AlexScript
AlexScript

Reputation: 849

WebBrowser Control does not open

when my event fires the following code get's run:

            WebBrowser browser = new WebBrowser();
        browser.Size = new Size(500, 500);
        browser.Dock = DockStyle.Fill;

        if (supportingInfo != null)
        {
            try
            {
                if (!String.IsNullOrEmpty(supportingInfo.Summary))
                {
                    browser.Navigate("about:blank");
                    if (browser.Document != null)
                    {
                        browser.Document.Write(string.Empty);
                    }
                    browser.DocumentText = "<html>" + supportingInfo.Summary + "</html>";

                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

I've debugged and every line of this get's run, but no new browser window opens with my dynamic html. What am I missing to make the window open with my html in it?

Thanks for all the help.

Upvotes: 0

Views: 862

Answers (2)

Nikkoli
Nikkoli

Reputation: 502

Looks like you are missing browser.Show()

Upvotes: 0

George Johnston
George Johnston

Reputation: 32258

You need to add the WebBrowser control you just created to the form/panel you want it to dock on. e.g.

  this.Controls.Add(browser);

You're just creating an instance of the browser and settings it's properties. No where have you actually added it visually.

Upvotes: 6

Related Questions