Webbrowser Control--- Text To HTML
-
Hi, I am trying convert Text to HTML. i am able to do this using the webbroswer control. My problem is something like this.. After assigning some text to the Webbrowser control i am not able to copy the contents from it immediately. But when i add a message box before copying or do the copy in a different event it works fine... i guess its something to do with the refresh, plz help me solve this. Below is the code i am trying.
IHTMLDocument2 doc; public WebBrowser browser; constructor.. { browser = new WebBrowser(); } click event.. { browser.DocumentText = "This is a test message //With this line contents are available. I want to do this without this line. **MessageBox.Show("Test");** doc = (mshtml.IHTMLDocument2)browser.Document.DomDocument; Clipboard.Clear(); doc.execCommand("selectall", false, null); doc.execCommand("Copy", false, null); RichTextBox r = new RichTextBox(); r.Paste(); Clipboard.Clear(); MessageBox.Show(r.Text.ToString()); }
-
Hi, I am trying convert Text to HTML. i am able to do this using the webbroswer control. My problem is something like this.. After assigning some text to the Webbrowser control i am not able to copy the contents from it immediately. But when i add a message box before copying or do the copy in a different event it works fine... i guess its something to do with the refresh, plz help me solve this. Below is the code i am trying.
IHTMLDocument2 doc; public WebBrowser browser; constructor.. { browser = new WebBrowser(); } click event.. { browser.DocumentText = "This is a test message //With this line contents are available. I want to do this without this line. **MessageBox.Show("Test");** doc = (mshtml.IHTMLDocument2)browser.Document.DomDocument; Clipboard.Clear(); doc.execCommand("selectall", false, null); doc.execCommand("Copy", false, null); RichTextBox r = new RichTextBox(); r.Paste(); Clipboard.Clear(); MessageBox.Show(r.Text.ToString()); }
I suspect the browser isn't fully initialized yet. Try calling DoEvents in place of the messagebox. I seem to remember a BrowserState or ReadyState property you can check as well. Check the state and wait until it is ready.
topcoderjax - Remember, Google is your friend.
-
I suspect the browser isn't fully initialized yet. Try calling DoEvents in place of the messagebox. I seem to remember a BrowserState or ReadyState property you can check as well. Check the state and wait until it is ready.
topcoderjax - Remember, Google is your friend.