Question Label.Text to display the current status

villy

Member
Joined
Feb 11, 2009
Messages
10
Programming Experience
Beginner
Hi all,

I would like to add in a progress bar and a status (label control) which will display what system doing after user click a button. There are few status:
Eg: Importing data, Verifying data, Generating Report

Part of my coding:
----------------------------------------------------------------------
Private Sub cmdImport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdImport.Click

ProgressBar1.Visible = True
lblStatus.Visible = True
lblStatus.Text = "Verifying Data File"

........
----------------------------------------------------------------------

lblStatus is the label which will display the current status.
But.. while user click the button, "Verifying Data File" is not displaying.
After the system complete the whole progress, lblStatus only display the text.
May I know any setting / bug I need to attend? Thanks.. :eek:
 
It sounds as you do lengthy work in UI thread, this work you should do in other thread. Look into BackgroundWorker component for starters.
 
Assuming your import is reading line by line in a loop; you can set the status of a label before the loop starts. Within the loop you can update your progress bar with each iteration but to update the label itself you would need to update the UI with each iteration such as calling Application.DoEvents. This will slow the running of your process.

Recommend a background worker as already suggested or limiting your display status to the progress bar while processing.
 
Back
Top