Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Winforms 窗口应用中的Web浏览器控件_Winforms - Fatal编程技术网

Winforms 窗口应用中的Web浏览器控件

Winforms 窗口应用中的Web浏览器控件,winforms,Winforms,您好,我正在使用此代码: private void Form1_Load(object sender, EventArgs e) { webBrowser1.Navigate("about:blank"); HtmlDocument doc = webBrowser1.Document; doc.Write("<b><i>My Name</i> is Not </b> Khan.&l

您好,我正在使用此代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        webBrowser1.Navigate("about:blank");

        HtmlDocument doc = webBrowser1.Document;
        doc.Write("<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.");
    }
    private void button1_Click(object sender, EventArgs e)
    {
        webBrowser1.Navigate("about:blank");
        HtmlDocument doc = webBrowser1.Document;
        doc.Write("<b><i>My Name</i> is Not </b> Khan.<b>");
    }
private void Form1\u加载(对象发送方,事件参数e)
{
webBrowser1.导航(“关于:空白”);
HtmlDocument doc=webBrowser1.文档;
写下(“我的名字不是可汗。我的名字不是可汗。我的名字不是可汗。我的名字不是可汗。”);
}
私有无效按钮1\u单击(对象发送者,事件参数e)
{
webBrowser1.导航(“关于:空白”);
HtmlDocument doc=webBrowser1.文档;
写下(“我的名字不是汗。”);
}
但当我单击按钮时,webBrowser1显示为空白。

请尝试以下代码:

    private void Form1_Load(object sender, EventArgs e)
    {
        string strText = "<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.<b><i>My Name</i> is Not </b> Khan.";
        webBrowser1.Navigate("about:blank");
        HtmlDocument objHtmlDoc = this.webBrowser1.Document;
        objHtmlDoc.Write(String.Empty);
        webBrowser1.DocumentText = strText;
    }
    private void button1_Click(object sender, EventArgs e)
    {
        string strText="<b><i>My Name</i> is Not </b> Khan.<b>";
        webBrowser1.Navigate("about:blank");
        HtmlDocument objHtmlDoc = this.webBrowser1.Document;
        objHtmlDoc.Write(String.Empty);
        webBrowser1.DocumentText = strText;
    }
private void Form1\u加载(对象发送方,事件参数e)
{
string strText=“我的名字不是汗。我的名字不是汗。我的名字不是汗。我的名字不是汗。”;
webBrowser1.导航(“关于:空白”);
HtmlDocument objHtmlDoc=this.webBrowser1.Document;
objHtmlDoc.Write(String.Empty);
webBrowser1.DocumentText=strText;
}
私有无效按钮1\u单击(对象发送者,事件参数e)
{
string strText=“我的名字不是汗。”;
webBrowser1.导航(“关于:空白”);
HtmlDocument objHtmlDoc=this.webBrowser1.Document;
objHtmlDoc.Write(String.Empty);
webBrowser1.DocumentText=strText;
}