如何更新进度条OnSelectedIndexChanged?

时间:2020-12-31 07:22:53

I am developing a Windows application using .NET (C#) and I have a DropDownList with some list items. On the event OnSelectedIndexChanged I need to display a progess bar, which should disappear after retrieving some data.

我正在使用.NET(C#)开发一个Windows应用程序,我有一个包含一些列表项的DropDownList。在事件OnSelectedIndexChanged上我需要显示一个progess栏,它应该在检索一些数据后消失。

I'm trying this way:

我正在尝试这种方式:

for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++)
{
    progressBar1.PerformStep();
}
panel1.Visible = false;

where my progress bar is placed in panel1, but I get the progress bar when I initially load my application. After that whenever the item is changed the progress bar is not visible. I need the solution asap...

我的进度条放在panel1中的位置,但是在我最初加载应用程序时,我得到了进度条。之后,每当更改项目时,进度条都不可见。我需要解决方案......

Thanks in advance!

提前致谢!

3 个解决方案

#1


Try panel1.Visible = true; at the start of your on selected index changed event of the combo box.

尝试panel1.Visible = true;在您选择的索引开始时更改了组合框的事件。

#2


I don't see the code that would make the Panel visible again and you would also need to reset the ProgressBar before updating it again by changing the Value property to zero.

我没有看到使Panel再次可见的代码,您还需要通过将Value属性更改为零来重新更新ProgressBar。

#3


private void comboBox1_SelectedIndexChanged(...)
{  
    progressBar1.Value=progressBar1.Minimum;
    panel1.Visible = true;
    for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++) 
    { 
    progressBar1.PerformStep(); 
    } 
    panel1.Visible = false
}

This should make the panel1 visible, however, I'm not sure what you mean by:

这应该使panel1可见,但是,我不确定你的意思是:

"and should disappear after retrieving some data"

“并且在检索一些数据后应该消失”

and if the solution of filling the progress bar solves it.

如果填充进度条的解决方案解决了它。

#1


Try panel1.Visible = true; at the start of your on selected index changed event of the combo box.

尝试panel1.Visible = true;在您选择的索引开始时更改了组合框的事件。

#2


I don't see the code that would make the Panel visible again and you would also need to reset the ProgressBar before updating it again by changing the Value property to zero.

我没有看到使Panel再次可见的代码,您还需要通过将Value属性更改为零来重新更新ProgressBar。

#3


private void comboBox1_SelectedIndexChanged(...)
{  
    progressBar1.Value=progressBar1.Minimum;
    panel1.Visible = true;
    for (int i = progressBar1.Minimum; i <= progressBar1.Maximum; i++) 
    { 
    progressBar1.PerformStep(); 
    } 
    panel1.Visible = false
}

This should make the panel1 visible, however, I'm not sure what you mean by:

这应该使panel1可见,但是,我不确定你的意思是:

"and should disappear after retrieving some data"

“并且在检索一些数据后应该消失”

and if the solution of filling the progress bar solves it.

如果填充进度条的解决方案解决了它。