private void button1_Click(object sender, EventArgs e)
        {
            
            webBrowser1.Navigate(@"about:blank");            webBrowser1.Document.OpenNew(true);
            webBrowser1.Document.Write(@"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'><html xmlns='http://www.w3.org/1999/xhtml'><body style=' margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px '>ssssssssss</body></html>");        }
当我点击一下鼠标时,在webBrowser1控件中能显示ssssssssss,但在点击一次的时候就我内容了,查看源文件时是<HTML></HTML>其它的什么也没有了

解决方案 »

  1.   

    webBrowser1.Navigate(@"about:blank");
                Application.DoEvents();
                webBrowser1.Document.OpenNew(true);
                webBrowser1.Document.Write(@" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'> <body style=' margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px '>ssssssssss </body> </html>"); 
      

  2.   

    哈哈,太感谢了,可以了,强!!!但不太清楚为什么要加这句呢?Application.DoEvents();