Progress bar for saving process
Can anybody help me for the following?
I want to show a small window with a message "Saving in progress" and a progress bar running, when I save the data to the database. I tried, but the small window get activated once the saving progress finished :confused:
Here is my code:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oMessage = New frmDialogBox
oMessage.show()
oMessage.Toplevel = True
Saving()
oMessage.close
End Sub
frmDialogBox form:
VB Code:
Private Sub DialogBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Label1.Text = "Loading In Progress..."
End Sub
Private Sub DialogBox_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Timer1.Enabled = True
Label1.Text = "Loading In Progress..."
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
If Not ProgressBar1.Value = ProgressBar1.Maximum Then
ProgressBar1.Value += 1
Else
ProgressBar1.Value = 0
End If
End Sub
Thanks :wave:
Re: Progress bar for saving process
Tru update your bar inside Saving(), while work is in process, using a different Thread, and everytime refresh your Label..
Re: Progress bar for saving process
Sorry Andyc,
Can't catch up u?
Am I doing in a right way?
some other code are also appreciable.
Re: Progress bar for saving process
Hi, i think you've only to add a thread to refresh the dialog box objects..
Button Click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim T as new Thread(AddressOf ThreadProc) 'Creates the new thread
Dim oMessage = New frmDialogBox
oMessage.showdialog(Me)
oMessage.Toplevel = True
Timer1.Enabled = True
Saving()
T.Abort()
oMessage.close
End Sub
Thread Procedure:
Public Sub ThreadProc()
If ProgBar.Value < 100 Then
ProgBar.Refresh()
ProgBar.Invalidate()
Label1.invalidate
Else
Timer1.Enabled = False
ProgBar.value = 0
End If
End Sub
Re: Progress bar for saving process
Sorry , my saving process is in different form (Form1) and frmDialogbox is a different form. I want to call frmDialog from Form1. How can I? :confused: