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);
}
}
精彩评论