Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 236461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:20:49+00:00 2026-05-11T20:20:49+00:00

How can I control IE form C#? I know that via COM you can

  • 0

How can I control IE form C#? I know that via COM you can do all sorts of interesting stuff, but looking at the SHDocVw namespace once I import the reference into my project there doesn’t seem to be that many methods. For example, how would I force a button to be clicked? Or set or read the value of a specific control on a page? In general, how can I individually control an object in IE though .NET?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:20:49+00:00Added an answer on May 11, 2026 at 8:20 pm

    Here are some samples from code I’ve written to control IE, maybe it can help:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
    
    //...
    
    void SetField(WebBrowser wb, string formname, string fieldname, string fieldvalue) {
      HtmlElement f = wb.Document.Forms[formname].All[fieldname];
      f.SetAttribute("value", fieldvalue);
    }
    
    void SetRadio(WebBrowser wb, string formname, string fieldname, bool isChecked) {
      HtmlElement f = wb.Document.Forms[formname].All[fieldname];
      f.SetAttribute("checked", isChecked ? "True" : "False");
    }
    
    void SubmitForm(WebBrowser wb, string formname) {
      HtmlElement f = wb.Document.Forms[formname];
      f.InvokeMember("submit");
    }
    
    void ClickButtonAndWait(WebBrowser wb, string buttonname,int timeOut) {
      HtmlElement f = wb.Document.All[buttonname];
      webReady = false;
      f.InvokeMember("click");
      DateTime endTime = DateTime.Now.AddSeconds(timeOut);
      bool finished = false;
      while (!finished) {
        if (webReady)
          finished = true;
        Application.DoEvents();
        if (aborted)
          throw new EUserAborted();
        Thread.Sleep(50);
        if ((timeOut != 0) && (DateTime.Now>endTime)) {
          finished = true;
        }
      }
    }
    
    void ClickButtonAndWait(WebBrowser wb, string buttonname) {
      ClickButtonAndWait(wb, buttonname, 0);
    }
    
    void Navigate(string url,int timeOut) {
      webReady = false;
      webBrowser1.Navigate(url);
      DateTime endTime = DateTime.Now.AddSeconds(timeOut);
      bool finished = false;
      while (!finished) {
        if (webReady)
          finished = true;
        Application.DoEvents();
        if (aborted)
          throw new EUserAborted();
        Thread.Sleep(50);
        if ((timeOut != 0) && (DateTime.Now > endTime)) {
          finished = true;
        }
      }
    }
    
    private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) {
      webReady = true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.