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 8071177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:37:42+00:00 2026-06-05T13:37:42+00:00

Everything works besides: links.Remove(linkToClick) since HtmlElementCollection doesn’t have a Remove method. I recently asked

  • 0

Everything works besides: links.Remove(linkToClick) since HtmlElementCollection doesn’t have a “Remove” method.

I recently asked a question here: How to have loop move to the next id available rather than doing the same continuously?

and that is what was recommended to me but I have been searching and trying to figure it out for the past two hours and still can’t figure it out.

HtmlElementCollection links = null;

private void button2_Click(object sender, EventArgs e)
{
    // This way you only get the links once.
    links = webBrowser1.Document.GetElementsByTagName("a");

    timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
    HtmlElement linkToClick = null;

    foreach (HtmlElement link in links)
    {
        if (link.GetAttribute("id").Contains("user"))
        {
            linkToClick = link;
            break;
        }
    }

    // did I find a link?
    if (linkToClick != null)
    {
        // Remove it from the list so you don't click it again.
        links.Remove(linkToClick);

        link.InvokeMember("click");
    }
}
  • 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-06-05T13:37:44+00:00Added an answer on June 5, 2026 at 1:37 pm
    List<HtmlElement> links = null;
    
    private void button2_Click(object sender, EventArgs e)
    {
        // This way you only get the links once.
        links = new List<HtmlElement>(webBrowser1.Document.GetElementsByTagName("a")
                                                          .Cast<HtmlElement>());
    
        timer1.Start();
    }
    
    private void timer1_Tick(object sender, EventArgs e)
    {
        HtmlElement linkToClick = null;
    
        foreach (HtmlElement link in links)
        {
            if (link.GetAttribute("id").Contains("user"))
            {
                linkToClick = link;
                break;
            }
        }
    
        // did I find a link?
        if (linkToClick != null)
        {
            // Remove it from the list so you don't click it again.
            links.Remove(linkToClick);
    
            linkToClick.InvokeMember("click");
        }
    }
    

    I would also suggest stopping the timer from within the timer if linkToClick == null, and why won’t you also FILTER the list in advance?

    links = new List<HtmlElement>(webBrowser1.Document.GetElementsByTagName("a")
                                                      .Cast<HtmlElement>());
    
    links.RemoveAll(link => !link.GetAttribute("id").Contains("user"));
    

    And in timer:

    if (links.Count > 0)
    {
        links[0].InvokeMember("click");
        links.RemoveAt(0);
    }
    // else timer.Stop();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# Application that I've wrote. Everything works 100% besides one method.
I have created a custom ExpandableListAdapter and everything works properly. What I'd like to
I have my pickerview set up and everything works fine, but right now I
iam using AVFoundation Framework to play mp3 file ,everything works great ، i have
I have a custom tabbar with custom tabbar items. Everything works as I want
Hi there I have edited some code I have found on-line and everything works
I recently converted a project from WPF 3.5 to WPF 4.0. Functionally, everything works,
Everything seems to work fine in the algorithm besides the solve method. When it
I have an app I am deploying to Heroku. Everything seems to work besides
Everything works as supposed to on the Django development server. In Apache, the django

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.