网页浏览器控件打不开
当我的事件触发以下代码时,get 会运行:
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;
}
}
我已调试并且该 get 的每一行都已运行,但没有使用我的动态 html 打开新的浏览器窗口。我缺少什么才能打开包含我的 html 的窗口?
感谢您的所有帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将刚刚创建的
WebBrowser
控件添加到您希望其停靠的表单/面板中。例如,您只是创建浏览器的实例并设置其属性。您实际上没有在视觉上添加它。
You need to add the
WebBrowser
control you just created to the form/panel you want it to dock on. e.g.You're just creating an instance of the browser and settings it's properties. No where have you actually added it visually.
看起来您缺少
browser.Show()
Looks like you are missing
browser.Show()