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. How to use IHTMLDocument2 with .NET 2.0 Webbrowser

How to use IHTMLDocument2 with .NET 2.0 Webbrowser

Scheduled Pinned Locked Moved C#
csharpvisual-studiotutorialquestion
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
    cweeks78681
    wrote on last edited by
    #1

    VS 2005 C# Express, .NET 2.0 The following code causes the Body member of the Webbrowser control to be set to null. Why? mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument; doc2.designMode = "On"; I am trying to programmatically select an element () in a web page listbox () the way a user would with the left mouse button. So, far I've found nothing that will do this.

    L 1 Reply Last reply
    0
    • C cweeks78681

      VS 2005 C# Express, .NET 2.0 The following code causes the Body member of the Webbrowser control to be set to null. Why? mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument; doc2.designMode = "On"; I am trying to programmatically select an element () in a web page listbox () the way a user would with the left mouse button. So, far I've found nothing that will do this.

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      cweeks78681 wrote:

      I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.

      What does that have to do with setting designMode to ON? :confused: Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript. You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.


      "What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike

      C 1 Reply Last reply
      0
      • L led mike

        cweeks78681 wrote:

        I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.

        What does that have to do with setting designMode to ON? :confused: Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript. You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.


        "What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum led mike

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

        > What does that have to do with setting designMode to ON? It was a shot in the dark. I thought maybe the HTMLDocument was in some kind of read-only state because I have NEVER found a way to modify a page in the web browser. Some kind of exception is always thrown. One said something about an access violation.

        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