Results 1 to 5 of 5

Thread: Progress bar for saving process

  1. #1

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    Exclamation 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

    Here is my code:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.     Dim oMessage = New frmDialogBox
    3.     oMessage.show()
    4.     oMessage.Toplevel = True
    5.     Saving()
    6.     oMessage.close
    7.     End Sub

    frmDialogBox form:
    VB Code:
    1. Private Sub DialogBox_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         Timer1.Enabled = True
    3.         Label1.Text = "Loading In Progress..."
    4.  
    5.     End Sub
    6.  
    7.     Private Sub DialogBox_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Activated
    8.         Timer1.Enabled = True
    9.         Label1.Text = "Loading In Progress..."
    10.     End Sub
    11.  
    12.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
    13.         If Not ProgressBar1.Value = ProgressBar1.Maximum Then
    14.             ProgressBar1.Value += 1
    15.         Else
    16.             ProgressBar1.Value = 0
    17.         End If
    18.     End Sub

    Thanks
    Last edited by haihems; May 9th, 2005 at 09:17 PM.
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

  2. #2
    Junior Member
    Join Date
    Jan 2005
    Location
    North Italy
    Posts
    28

    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..

  3. #3

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    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.
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

  4. #4
    Junior Member
    Join Date
    Jan 2005
    Location
    North Italy
    Posts
    28

    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

  5. #5

    Thread Starter
    Addicted Member haihems's Avatar
    Join Date
    Oct 2004
    Posts
    150

    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?
    Think Before Ink

    Visual Studio .NET 2002/.NET Framework 1.0

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width