0
我正在開發windows窗體聊天應用程序,並且我正在richtextbox中撰寫消息,但是當我點擊發送按鈕並且每個消息都顯示在webbrowser控件中時。 。我要動態地添加WebBrowser控件個別消息send.i正在使用下面的代碼:在windows聊天應用程序中動態添加webbrowser控件:
namespace WindowsFormsApplication1
{
[ComVisible(true)]
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
// this.w1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(w1_DocumentCompleted);
}
WebBrowser w1 = new WebBrowser();
private void button1_Click(object sender, EventArgs e)
{
this.Controls.Add(w1);
HtmlElement div = w1.Document.GetElementById("abc");
div.InnerHtml = richTextBox1.Text;
}
private void Form1_Load(object sender, EventArgs e)
{
w1.Navigate(Path.Combine(Environment.CurrentDirectory, "HTMLPageForScripting.htm"));
}
}
}