CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2007
    Posts
    17

    Question help required to use progress bar

    hello

    I m using progress bar in my vb.net application on loading records in datagrid

    but problem arises that progress bar moves after loading the data grid

    i want this to load with load time or before loading the grid
    as progress bar completes it will show the records

    plz reply soon

    thanks in advance

  2. #2
    Join Date
    Apr 2002
    Location
    Egypt
    Posts
    2,210

    Re: help required to use progress bar

    How do you increment the progress bar? on what event?
    Can you post the code?
    Hesham A. Amin
    My blog , Articles


    <a rel=https://twitter.com/HeshamAmin" border="0" /> @HeshamAmin

  3. #3
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: help required to use progress bar


  4. #4
    Join Date
    Oct 2007
    Posts
    17

    Exclamation Re: help required to use progress bar

    i used the code as

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            If (Me.mkc_ProgressBar1.Value >= 0) Then
                Me.mkc_ProgressBar1.Value += 1
            Else
                Me.Timer1.Enabled = False
            End If
        End Sub
    
    Private Sub btn_Show_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_Show.Click
            Me.mkc_ProgressBar1.Value = 0
            Me.Timer1.Interval = 1
            Me.Timer1.Enabled = True
            ShowSample()
    End Sub
    
    <Description("The value used to generate progress based on the maximum value."), Category("Custom")> _
    		Public Property Value() As Integer
    			Get
    				Return val
    			End Get
    
    			Set(ByVal Value As Integer)
    				Dim oldValue As Integer = val
    
    				' Make sure that the value does not stray outside the valid range.
    				If (Value < min) Then
    					val = min
    				ElseIf (Value > max) Then
    					val = max
    				Else
    					val = Value
    				End If
    
    				' Invalidate only the changed area.
    				Dim percent As Decimal
    
    				Dim newValueRect As Rectangle = Me.ClientRectangle
    				Dim oldValueRect As Rectangle = Me.ClientRectangle
    
    				' Use a new value to calculate the rectangle for progress.
    				percent = (val - min) / (max - min)
    				newValueRect.Width = newValueRect.Width * percent
    
    				' Use an old value to calculate the rectangle for progress.
    				percent = (oldValue - min) / (max - min)
    				oldValueRect.Width = oldValueRect.Width * percent
    
    				Dim updateRect As Rectangle = New Rectangle
    
    				' Find only the part of the screen that must be updated.
    				If (newValueRect.Width > oldValueRect.Width) Then
    					updateRect.X = oldValueRect.Size.Width
    					updateRect.Width = newValueRect.Width - oldValueRect.Width
    				Else
    					updateRect.X = newValueRect.Size.Width
    					updateRect.Width = oldValueRect.Width - newValueRect.Width
    				End If
    
    				updateRect.Height = Me.Height
    				' Invalidate only the intersection region.
    				Me.Invalidate(updateRect)
    			End Set
    		End Property		 'Value() As Integer
    Last edited by HanneSThEGreaT; October 19th, 2007 at 01:05 AM.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: help required to use progress bar

    saimasattar, please read this before posting again. Using proper &#091;CODE] and &#091;/CODE] tags, makes code much easier to read!

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

Featured