Updating ToolStripProgressBar and ToolStripStatusLabel along with with an action
Posted
by TChristian
on Stack Overflow
See other posts from Stack Overflow
or by TChristian
Published on 2010-06-15T21:04:40Z
Indexed on
2010/06/16
13:42 UTC
Read the original article
Hit count: 289
In a Windows Form, I have a search box that fires an event to search a remote database and display some results. The query is pretty fast, usually just a fraction of a second, but in case the delay is noticeable there is a progress bar and label in the form's status bar. When the user clicks "Search" the status label should appear and the progress bar show some progress. Then when the result comes back the label should disappear and the progress bar should be full. Pretty basic response.
The problem is, I can't get those actions to happen in that order. Using the code below, I click "Search", nothing happens until the results are displayed, and then the progress bar fills up from 0 to 100. The label never appears. I even threw in a sleep command immediately after the event to be sure I wasn't just missing it, but it's as if the first 2 statements are not being executed. What am I doing wrong here?
private void searchButton_Click(object sender, EventArgs e)
{
toolStripStatusLabel1.Visible = true;
toolStripProgressBar1.Value = 20;
m_changeRequestedEvents.Fire<String>("SearchTerm", searchTextBox.Text);
toolStripProgressBar1.Value = 100;
toolStripStatusLabel1.Visible = false;
}
© Stack Overflow or respective owner