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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:36:48+00:00 2026-05-20T07:36:48+00:00

In my application a ListBox is filled after a user puts more than two

  • 0

In my application a ListBox is filled after a user puts more than two characters into a textBox.

If there is a lot to fill into the ListBox, the user has to wait until the ListBox is completely filled before is able to continue his input.

Now I need a solution to fill the ListBox without blocking the UI, so I would like to use a background worker to solve this.

—- Original Version —–

In my application I fill a ListBox when the user puts in more then two characters into a textBox.
The ListBox fills with results and after this, the user is able to put in more characters.

My problem is the following behaviour: The user is only able to put in the next char after the whole ListBox is filled with all entries. If there are a lot of results the user has to wait until he is able to continue.

I would like to have the following behaviour: If the user puts in a char, the filling of the ListBox should stop and build the list for the new input.

I thought about sth. like:

[PSEUDO-CODE]
loop over results {
    if (UserInput) {    // <-- GetKeyState()?
        break
    }

    AddOneItemToListBox
}
[/PSEUDO-CODE]

I thought about sth. like GetKeyState() but I think there should be a more elegant way (perhaps a control or another technology I don’t know about ATM).

P.S.: Currently I’m looking for a solution with .Net2.0, but if there is a technology inside a later version of .Net I would also be glad for a short hint (just for my information).

  • 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-20T07:36:48+00:00Added an answer on May 20, 2026 at 7:36 am

    You can fill the the ListBox within a BackgroundWorker (don’t forget to call the Add() method with BeginInvoke()). In this case the user can already interact with the GUI while the box will be filled.

    If the user adds something to the box on himself you can stop the autofill by calling worker.CancelAsnyc().

    Update (compatible with VS 2005)

    Unfortunately i don’t have VS2005 to try it out, but i removed all the fancy lambda, etc. stuff.

    Just a simple sample for starting:

    public partial class FormMain : Form
    {
        BackgroundWorker _Worker;
    
        public FormMain()
        {
            InitializeComponent();
    
            _Worker = new BackgroundWorker();
    
            _Worker.DoWork += OnWorkerDoWork;
            _Worker.WorkerSupportsCancellation = true;
    
            this.Shown += OnFormMainShown;
        }
    
        void OnFormMainShown(object sender, EventArgs e)
        {
            _Worker.RunWorkerAsync();
        }
    
        void OnWorkerDoWork(object sender, DoWorkEventArgs e)
        {
            for (int i = 0; i < 100; i++)
            {
                if (_Worker.CancellationPending)
                {
                    return;
                }
    
                Thread.Sleep(100);
                listBox1.Invoke((Action<int>)AddItem, i);
            }
        }
    
        private void AddItem(int i)
        {
            listBox1.Items.Add(i);
        }
    
        private void button1_Click(object sender, EventArgs e)
        {
            _Worker.CancelAsync();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Application: WPF Application consisting of a textbox on top and a listbox below Users
In my WPF application there is a listbox with items. The listbox is populated
In my application using DataTemplate mechanism I insert into ListBox item another listbox. But
I am creating some kind of chat style application. The Listbox is getting filled
I have two ListBox in my winforms application, I assigne a datasource for both
I have a Windows Forms application (C#) containing a ListBox into which I have
I have listbox, button, and textbox controls in a Windows application. How can I
I've got a Windows Forms application with two ListBox controls on the same form.
There is a horizontal ListBox (of Images) in my application. At application startup, I
In my application there is one Listbox and one textblock both are coupled inside

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.