Progress Bar Help!

Guys, i am currently developing a program that has an MDIForm, and this MDIForm contains a status bar with a progress bar... What I wanted to do is whenever i want to load a form.. I want my progressbar to increment its value. Like that of an internet explorer... Did anyone encountered this problem already




Answer this question

Progress Bar Help!

  • JulianaMassara

    What problem to be exact Are you doing something upon loading a Form

    Regards,

    -chris

  • Vasu Sankaran

    Hi Franco,

    A couple of questions:

    1. When you click a MenuItem, are you loading a form
    2. When you load a form, are you doing something else before the form get displayed on to the screen

    If your answer to 1. and 2. is both yes, then you should make your progressbar accessible outside the MDIForm, hence you're accessing it from the MDIParent:




    // *value* should be replaced by actual value
    ((MyMDI)this.MDIParent).MyProgressBar.Value = *value*;




    And if you want this to be done while the form is loading, then call the Show method of the form inside the Form_Load event:



    private void Form1_Load(object sender, System.EventArgs e)
    {

    // Display the form to the screen
    this.Show();
    Application.DoEvents();

    // Do your thing here that requires progress report
    .
    ..
    ...

    ((MyMDI)this.MDIParent).MyProgressBar.Value = *value*;

    }



    Hope this helps,

    -chris

  • Larry_Pope

    Dim t As ToolStripProgressBar = StatusStrip1.Items("ToolStripProgressbar1")

    For i As Int16 = t.ProgressBar.Minimum To t.ProgressBar.Maximum
    Application.DoEvents()
    System.Threading.Thread.Sleep(100)
    t.ProgressBar.Value = i
    Next


  • Sam Norris

    You can place this code in the button_click


  • smiley78

    Thanks Fahad Mukhtar for taking time to answer my question..

    Where will I place your code Fahad Mukhtar

    Do you have a sample project that does the same thing with what i want

    May I know ur Yahoo Messenger ID

     



  • Darkbob

    Hey Guys I got it working already.../

    Hehehehe....

    Without threading... Below is my code for the child load event...

    private void PatientMasterList_Load(object sender, EventArgs e)

    {

    this.Show();

    //Application.DoEvents();

    ((Form1)this.MdiParent).progressBar1.Minimum = 0;

    ((Form1)this.MdiParent).progressBar1.Step = 1;

    ((Form1)this.MdiParent).progressBar1.Maximum = 200;

    //while (!this.Focus())

    //{

    //System.Threading.Thread.Sleep(100);

    for (int i = 0; i < ((Form1)this.MdiParent).progressBar1.Maximum; i++)

    {

    ((Form1)this.MdiParent).progressBar1.PerformStep();

    ((Form1)this.MdiParent).progressBar1.Value += 1;

    if (((Form1)this.MdiParent).progressBar1.Value == ((Form1)this.MdiParent).progressBar1.Maximum)

    {

    break;

    }

    }

    dataGridView1.DataSource = AccessDBase.dtGeneral(boObjects.cmdSQL, "tblSample");

    bindingNavigator2.BindingSource = new BindingSource(AccessDBase.dsGeneral(boObjects.cmdSQL, "tblSample"), "tblSample");

    if (((Form1)this.MdiParent).progressBar1.Value == ((Form1)this.MdiParent).progressBar1.Maximum)

    {

    ((Form1)this.MdiParent).progressBar1.Value = 0;

    }

    }

    Thanks Chris Vega and Faha Mukhtar....



  • Tree Hugger

    Chris, the scenario is this: I have an MDIParent Form with menu strip in it. Whenever I want to click a menu item in the menustrip control, I want the toolstripprogressbar to increment its value so that the user will know that the application is doing something...

    Thank you for your time Chris Vega.



  • vatsan

    Chris It worked but my application hunged up...

    Here is my code:

    //MDIParent

    private void patientsToolStripMenuItem_Click(object sender, EventArgs e)

    {

    frmPM.MdiParent = this;

    frmPM.Show();

    }

    //Child Form Load event

    private void PatientMasterList_Load(object sender, EventArgs e)

    {

    Application.DoEvents();

    ((Form1)this.MdiParent).progressBar1.Minimum = 0;

    ((Form1)this.MdiParent).progressBar1.Step = 1;

    ((Form1)this.MdiParent).progressBar1.Maximum = 100;

    while (!this.Focus())

    {

    ((Form1)this.MdiParent).progressBar1.PerformStep();

    }

    dataGridView1.DataSource = AccessDBase.dtGeneral(boObjects.cmdSQL, "tblSample");

    bindingNavigator2.BindingSource = new BindingSource(AccessDBase.dsGeneral(boObjects.cmdSQL, "tblSample"), "tblSample");

    this.Show();

    }



  • wazhoo

    Fahad Mukhtar I have read your reply, I really appreciate ur help...

    Where to be specific, after Form.Show(); or before Form.Show();

    Dont worry, im not lazy, i am also trying my own ideas... and tried research on this thing...



  • Henrylau

    Chris, does this mean that I have to get a BackgroundWorker component and create another thread

    To be honest, I have no clear understanding yet of how multithreading works. I didnt get into that topic because I have read an article that it is risky..

    Chris Thank you so much for ur time... Do you have a sample application that does the same thing

    1. When I click a MenuItem, I am loading a form.
    2. When I am in the process of loading the child form, I want my progress bar to start working.

    Chris Vega, I really need your help, I think u have worked on this kind of problem before..

    Thanks again for ur time...



  • Calvin_42

    Yes sir..

    I want my toolStripProgressBar to increment its value whenever I want to load a child form.



  • Progress Bar Help!