vb.net webbrowser控件如何获取鼠…

来源:互联网 发布:java读取gz文件内容 编辑:程序博客网 时间:2024/05/17 18:42
首先添加引用Microsoft.mshtml,具体操作项目->添加引用->.NET找到添加就行
需要的控件webbrowser一个,button一个,如果名字不是默认请修正代码中控件名字。
然后代码如下即可:在vs2010, 【.net4.0下调试通过】Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click        '获取用户选中的文字    Dim htmlDocument As mshtml.IHTMLDocument2  'IHTMLDocument2        htmlDocument = WebBrowser1.Document.DomDocument        Dim currentSelection As mshtml.IHTMLSelectionObject        currentSelection = htmlDocument.selection        Dim range As mshtml.IHTMLTxtRange        If Not (currentSelection Is Nothing) Then            range = currentSelection.createRange()            If Not (range Is Nothing) Then                MsgBox(range.text)       ‘可以进行你希望的操作                   End If        End If    End Sub
0 0
原创粉丝点击