How to copy text from webbrowser/Frame Control (WPF)

  • Thread starter Thread starter claton
  • Start date Start date
C

claton

Hello,

I've added a webbroswer control in my WPF application, As the app loads up,
it naviagates to a site then How do I copy text from the site using code. I
can successfully do this in WinForms using WebBrowser1.Document.DomDocument
not able to do the same in WPF webbrowser control.
Any tips.

Thanks in Advance!

Regards,
Claton
 
Thank you Bjarte for replying,
I have checked the msdn and the property document is a bit different than
the WinForm WebBrowser. I have the following code in Winform

Public Class Form1
Dim doc As mshtml.HTMLDocument
Dim txtRange As mshtml.IHTMLTxtRange
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("www.microsoft.com")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
txtRange = doc.selection.createRange()
MessageBox.Show(txtRange.text.ToString())
End Sub

Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal
e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles
WebBrowser1.DocumentCompleted
doc = Me.WebBrowser1.Document.DomDocument
End Sub
End Class
 
Back
Top