progressbar while loading data from database

ruudboy

New member
Joined
Mar 9, 2009
Messages
1
Programming Experience
1-3
VB.NET:
    Sub laad_leden()
        Dim myConnection As New connectdb
        Dim tabel As New DataTable
        Dim i As Integer
        tabel = myConnection.SelectTable("SELECT * FROM tbl_leden " & check_where & " ORDER BY lid_naam ASC")

        Me.Text = "NLC-Clan"
        pbar.Minimum = 0
        pbar.Maximum = 100
        pbar.Value = 0

        For i = 0 To tabel.Rows.Count - 1
            chkLeden.Items.Add(tabel.Rows(i)(1))

            Dim chkCOD4 As New CheckBox
            chkCOD4.Name = "chkCOD4_" & i + 1
            chkCOD4.Size = New System.Drawing.Size(15, 14)
            chkCOD4.Location = New System.Drawing.Point(388, 2 + i * 17)
            chkCOD4.Enabled = False
            Controls.Add(chkCOD4)
            chkLeden.Controls.Add(chkCOD4)

            Dim chkCOD5 As New CheckBox
            chkCOD5.Name = "chkCOD5_" & i + 1
            chkCOD5.Size = New System.Drawing.Size(15, 14)
            chkCOD5.Location = New System.Drawing.Point(445, 2 + i * 17)
            chkCOD5.Enabled = False
            Controls.Add(chkCOD5)
            chkLeden.Controls.Add(chkCOD5)

            If tabel.Rows(i)(6) = 1 Then
                chkCOD4.Checked = True
            End If
            If tabel.Rows(i)(7) = 1 Then
                chkCOD5.Checked = True
            End If
            pbar.Step = 30
            pbar.Refresh()

        Next
        pbar.Visible = False
        lblPbar.Visible = False

    End Sub

    Private Sub chkWCOD4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkWCOD4.CheckedChanged
        If chkWCOD4.Checked = True Then
            If chkWCOD5.Checked = True Then
                check_where = "WHERE lid_cod4='1' AND lid_cod5='1'"
            Else
                check_where = "WHERE lid_cod4='1'"
            End If
        Else
            If chkWCOD5.Checked = True Then
                check_where = "WHERE lid_cod5='1'"
            Else
                check_where = "WHERE 1=1"
            End If
        End If
        lblPbar.Visible = True
        chkLeden.Controls.Clear()
        pbar.Visible = True
        Me.Refresh()
        chkLeden.Items.Clear()
        laad_leden()
    End Sub
While loading the data to the program the window freezes. It shows the progressbar but the progressbar is also freezing.
How can i let the progressbar marquee while loading / freezing.
 
Back
Top