Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Webbrowser Control--- Text To HTML

Webbrowser Control--- Text To HTML

Scheduled Pinned Locked Moved C#
helphtml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    chettu
    wrote on last edited by
    #1

    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()); }

    D 1 Reply Last reply
    0
    • C chettu

      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()); }

      D Offline
      D Offline
      Dave Herren
      wrote on last edited by
      #2

      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.

      C 1 Reply Last reply
      0
      • D Dave Herren

        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.

        C Offline
        C Offline
        chettu
        wrote on last edited by
        #3

        Thank you so so soooooo much... That absolutely saved my day.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups