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

  • SEARCH
  • Home
  • 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 909377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:52:03+00:00 2026-05-15T16:52:03+00:00

Since you can only assign it after the document have been loaded, and you

  • 0

Since you can only assign it after the document have been loaded, and you don’t need to assign it every time a document loads, do I just don’t have other choice than to do something like this?

private void WebBrowser_DocumentCompleted(object sender,
    WebBrowserDocumentCompletedEventArgs e)
{
    if (!mouseDownAssigned) // mouseDownAssigned is a bool with start value false
    {
        mouseDownAssigned = true;
        this.Document.MouseDown += 
            new HtmlElementEventHandler(Document_MouseDown);
    }
}

Which is kinda ugly and not elegant. Got a feeling this is not what Microsoft had in mind.

  • 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-15T16:52:04+00:00Added an answer on May 15, 2026 at 4:52 pm

    I think this is the closest to an elegant solution:

        public MyWebBrowser()
        {
            InitializeComponent();
            this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SuperWebBrowser_DocumentCompleted);
            this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(SuperWebBrowser_DocumentFirstCompleted);
        }
    
        private void SuperWebBrowser_DocumentFirstCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            this.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(SuperWebBrowser_DocumentFirstCompleted);
            this.Document.MouseDown += new HtmlElementEventHandler(Document_MouseDown);
        }
    
        private void SuperWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
        }
    

    That way I don’t need to check a variable every time a document completes. Guess that’s kinda what Microsoft had in mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since arrays and hashes can only contain scalars in Perl, why do you have
Since Postgres can only add columns at the end of tables, I end up
I want to run an Apache on my local machine since I can only
I know it can't be done since using var can only be done for
Is it possible to have an issues list in sharepoint where users can only
Alright, I have some data that I need to assign an int type identifier
Since I can't use Microsoft as an example for best practice since their exception
Since I can't put up a screenshot of my storyboard, I'll try to explain:
The following code gives a NullReferenceException since XPathSelectElement can't navigate through the XPath expression
Situation: Site with content protected by username/password (not all controlled since they can be

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.