开发者

How to get content in webBrowser control

Assume I type uri in a t开发者_开发百科extbox and click a button load, a web page is loaded into my webbrowswer control, then I highlight a piece of text in the webbroswer control. And now, how can I get hightlighted text and display in another textbox? (no copy/paste)

Thanks!


Retrieving Selected Text from Webbrowser control in .net(C#)

    IHTMLDocument2 htmlDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;

    IHTMLSelectionObject currentSelection= htmlDocument.selection;

    if (currentSelection!=null) 
    {
        IHTMLTxtRange range= currentSelection.createRange() as IHTMLTxtRange;

        if (range != null)
        {
            MessageBox.Show(range.text);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜