![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to copy text from webbrowser/Frame Control (WPF) 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 |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to copy text from webbrowser/Frame Control (WPF) The document should be available in the WebBrowser object. There's a property named Document. http://msdn.microsoft.com/en-us/libr...r_members.aspx -- regards Bjarte Skogøy "claton" <claton@xxxxxx> skrev i nyhetsmeldingen: BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ... Quote: > 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 > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to copy text from webbrowser/Frame Control (WPF) 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 ------------------ but when I try to use the WPF webbrowser it does not have extented properties to the Document just like the winForm Document.DomDocument. - Claton "Bjarte Skogøy" wrote: Quote: > The document should be available in the WebBrowser object. There's a > property named Document. > http://msdn.microsoft.com/en-us/libr...r_members.aspx > > > -- > regards > Bjarte Skogøy > > "claton" <claton@xxxxxx> skrev i nyhetsmeldingen: > BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ... Quote: > > 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 > > > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to copy text from webbrowser/Frame Control (WPF) okie! I found the answer here http://www.rhizohm.net/irhetoric/blog/72/default.aspx you need to type cast MSHTML to the webbrowser.document so access the contents/text on the navigated URL. Hope this helps others too.. ~ Claton "claton" wrote: Quote: > 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 > ------------------ > but when I try to use the WPF webbrowser it does not have extented > properties to the Document just like the winForm Document.DomDocument. > > - Claton > > "Bjarte Skogøy" wrote: > Quote: > > The document should be available in the WebBrowser object. There's a > > property named Document. > > http://msdn.microsoft.com/en-us/libr...r_members.aspx > > > > > > -- > > regards > > Bjarte Skogøy > > > > "claton" <claton@xxxxxx> skrev i nyhetsmeldingen: > > BE05FA45-B854-4032-8524-2CCF499CA176@xxxxxx ... Quote: > > > 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 > > > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| How do I debug JavaScript in a WebBrowser control? | .NET General | |||
| automating ie or webbrowser control | VB Script | |||
| is the dotnet 2 webbrowser control based on IE 6 or 7? | .NET General | |||
| Printint the content of a webbrowser control | .NET General | |||