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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:35:33+00:00 2026-05-15T11:35:33+00:00

I’ve run into a problem where I want to display a list of items

  • 0

I’ve run into a problem where I want to display a list of items in a checkListBox and programmatically check them off one by one as each process I am monitoring gets completed.

I will try to water my code down to the bare essentials so everyone can easily grasp what is happening.

for (int i = 0; i < 10; i++)
{
    SOME_FUNCTION();
    progressBar.Value++;
    checkListBoxItems.SetItemCheckState(i, CheckState.Checked);
}

This is essentially what my code is doing. The progress bar gets updated while the loop is running, but all of the check boxes do not get checked until the loop is finished and they are all checked at the same time.

This obviously defeats the purpose of displaying the check boxes and I was curious if there was something I was missing that allows you to refresh the checkListBox control, or something similar.

I apologize if this question seems vague, I seem to have that problem quite often here.

  • 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-15T11:35:34+00:00Added an answer on May 15, 2026 at 11:35 am

    This is standard behavior for any Windows GUI application, screen updates don’t happen until the UI thread goes idle so that Windows can deliver the Paint event. One of the absolute worst things you could do is calling Application.DoEvents(). Yes, that will deliver the Paint event. But it also allows your user to close the form. That produces a Big Kaboom when the control you are trying to update is suddenly not there anymore. Your loop is still running, but the form isn’t there anymore.

    What you must have noticed is that the progress bar actually updated but the CheckedListBox did not. That’s because ProgressBar often is used to show progress when the code is in a loop, so it makes sure that when you change the Value property, it immediately paints itself without waiting for Windows to tell it that it needs to be repainted. Dirty trick, very confusing.

    But you can take advantage of that trick as well, it is easy. Modify your code like this:

    for (int i = 0; i < 10; i++)
    {
        SOME_FUNCTION();
        progressBar.Value++;
        checkListBoxItems.SetItemCheckState(i, CheckState.Checked);
        checkListBoxItems.Update();
    }
    

    The Update() method means “paint yourself when necessary”. It is, you changed the check state of an item. Never does the Big Kaboom thingy on you, the user can’t suddenly make the control disappear.

    If SOME_FUNCTION() takes a long time, like more than 10 x 0.3 seconds or so, then you should start thinking about using threads.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
i want to parse a xhtml file and display in UITableView. what is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,

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.