In Windows Application,A ProgressBar control, Which is available in ToolBox, is used to represent the progress of a lengthy operation that takes time where a user must wait for the operation to be finished.
Below is the code when you try to show progressbar while foreach loop is running. same concept you can apply for for loop.
public void btnSubmit_Click(object sender, EventArgs e)
{
//Drag and drop progressBar on Window form. and use that progressbar object in C# code
progressbar.Minimum =0;
// Here you can defined the no. of count required in for OR foreach loop
progressBar.Maximum = 100;
foreach(string value in values)
{
//Define all others logic
progressbar.value +=1;
progressbar.Refresh();
}
}
Leave a comment