標籤:winform style blog http color os
Winform程式 2.0的. 需要引用Microsoft.mshtml.
private void Form1_Load(object sender, EventArgs e) { webBrowser1.Navigate("http://www.baidu.com"); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); } void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { webBrowser1.Document.MouseUp += new HtmlElementEventHandler(Document_MouseUp); } void Document_MouseUp(object sender, HtmlElementEventArgs e) { IHTMLDocument2 document = (IHTMLDocument2)webBrowser1.Document.DomDocument; IHTMLTxtRange htmlElem = (IHTMLTxtRange)document.selection.createRange(); string s = htmlElem.htmlText; richTextBox1.Text = s; }
View Code
需要看document.selection.createRange();類型 需要引用Microsoft.VisualBasic. 用Microsoft.VisualBasic.Information.TypeName(document.selection.createRange());方法查看類型.
差不多就這些了~ 不知道每次記錄這些遇到的問題 能協助別人不..- -|