Q:

Progressbar not showing while doing calculation

I have created a windows form in C#.
in this form I have a "Calculation Button" and a ProgressBar
When I click the Calculation button, a user control is generted and in this user control some caculation are made. I want the progressbar to show the progress of the caculation made in the usercontrol.
in the Main Form I havae this code:
public Main()
{
   InitializaComponent()
}
private void Btn_PVT_Validar_Click(object sender, EventArgs e)
{
       progressbar.Visible = true;
       progressbar.Maximum=115;
       M_Results m_Results = new M_Results()
       m_Results.Visible = true;
}

in the userControl i have this:
public Results()
{
   InitializaComponent()
}
 private void Results_Load(object sender, EventArgs e)
 {
        Control parent = this.Parent as Control;
        pbar = parent.Controls["progressbar"] as radProgressBar;
        dens();
 }
private void dens()
{
 //loop calculattion and other stuffs and in each loop i have this:
 pbar.value1=pbar.value1+2;
}

the progressabar progress is not being shown, just when everything finish, the progressbar appears and is full.
what should I do?
Thanks Carlos

A:

Use Application.DoEvents() evrytime you change progressbar value:
private void dens()
{
   pbar.value1=pbar.value1+2;
   Application.DoEvents();
}

