VB.NET Please Wait window from form

I have a form that exports a loaded datagridview  to excel.  When exporting, I would like the user to see a 'please wait' panel / form with a progress bar.

Can anyone advise the best way to do this?

The solution should be dynamic in that the export process can work from more than one datagridview.
mondintatorAsked:
Who is Participating?
 
Jacques Bourgeois (James Burger)Connect With a Mentor PresidentCommented:
Well, very simple.

Have the stuff you want to display in a Control over the others, say lblWait.

Open the form, lblWait display the waiting message.

Do what you need to do.

Then:  lblWait.Visible = False

As long as a control is invisible, it is just as if it did not exist.
0
 
Bob LearnedCommented:
I see a tag for the BackgroundWorker.  Is that the direction that you are hoping to take?  Have you tried anything yet?  How can I help?
0
 
mondintatorAuthor Commented:
I have it currently working by opening a new form via a separate thread, and I cancel the thread when done.  But it's not ideal as it's opening a new form.  I like the idea of the background worker because it doesn't cause rendering issues to the form when the other thread is running, and can look like it's embedded in the form.  But I can't get it to work as per the other thread.  So I thought I'd ask the best / recommended way to approach this.  My code for the backgroundworker is on the other query.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Jacques Bourgeois (James Burger)PresidentCommented:
Instead of using another form, you could use a StatusStrip control at the bottom of the form. The StatusStrip provided with the framework offers the option of displaying a progress bar.

Since it is on the same form, no need to define a way to control the progress bar in the waiting form from the original form.

And the green color used to show the progress is bold enough that the user's sight is automatically attracted to it, so even users who do not have the habit of looking at status bars will see it.
0
 
mondintatorAuthor Commented:
A status strip is good, but I'd like to disable all of the screen and show an animated gif with the progress bar, and the option of cancelling the process.  Are there any other options?
0
 
rajeeshmcaCommented:
0
 
mondintatorAuthor Commented:
Splash screen is good, but the splash screen has it's own icon if I alt + tab between applications, rendering my main form unaccessable because it's doing work (on a different thread).  How can I get my main form to display whilst it's doing the work, with the splash screen embedded into the form where the gif image is not affected?
0
 
hjgodeCommented:
I dont understand your requirements in complete. Sorry

You have a form with a datagrid. You enable the user to export the grid data to excel. You want to show a Progress Window with animated GIF and a Cancel button but dont want to use a new form and the actual form should be disabled. Correct?

If you dont want a new form, why not just have another contents of the form with animated GIF and Cancel button? Just design two contents in one form and make the one visible you like.

One answer here suggested to create a splash screen and your concern was that there are now two buttons visible in taskbar. There are functions to hide the button from the taskbar. So you could go with a second form without a button in taskbar.

If you still need assistance I would prefer to see a sketch of what you want to achieve.
0
 
HooKooDooKuCommented:
I don't have much experience specifically in VB.NET, but back in my VB6 days (which was single threaded) what I would do is have a form with a progress bar, an abort button, and a label control.  I gave the form the boolean property m_Abort.  I then had functions which pseudo code that looked like this (but with error checking and error handling):

Start( Max as integer)
    progressbar.max = Max
    progresbar.value = 0 
    label.caption = cstr(progresbar.value) & " of " & cstr(progressbar.max)
    m_Abort = False

SetPosition(Value as integer)
    progressbar.value = Value
    label.caption = cstr(progresbar.value) & " of " & cstr(progressbar.max)

Inc()
    progressbar.value = progressbar.value + 1
    label.caption = cstr(progresbar.value) & " of " & cstr(progressbar.max)  

AbortProcess as Boolean
    DoEvents '(allowed form to respond to click events on abort button
    return m_Abort

OnAbortClicked
    if( MessageBox("Are you sure?") = Yes )
        m_Abort = true

Open in new window


Then in my processing loop, I simply called
if( PleaseWaitForm.AbortProcess )
    exit process               

Open in new window


Again, this is pseuodcode... but the basic idea was that calling the AbortProcess function gave the PleaseWait form the ability to respond to click events or drag-and-drop events, if Abort was ever clicked, a conformation message popped up, and if the Abort Button was ever confirmed, AbortProcess would return TRUE until the form was restarted.
0
 
mondintatorAuthor Commented:
The main issue I have with a separate form / splashscreen is that when the main form is performing it's task, if I alt+tab to display my form it doesn't display (because it's busy).  Instead I can display the splash screen only.  I would like a solution that allows me to display my main form whilst it is performing the work, but with the 'please wait' image 'on top'.  The solutions suggested thus far do not allow for this.
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
Put the "Please Wait" image in a control (Label, PictureBox, UserControl) that sits over the other ones on the form. Since that control is part of the form. When the form has finished initializing, simply set the control Visible property to False.
0
 
mondintatorAuthor Commented:
Thanks James - I think that will do it - I will give it a try.  Do you have any example code?
0
 
hjgodeCommented:
Do not forget to disable the other controls. If you do not disable, the user is able to use TAB to cycle the focus thru them and SPACE or ENTER may execute unwanted.
The TAB will work alos for controls behind other controls.
0
 
mondintatorAuthor Commented:
All of James' advice proved useful.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.