sequential order

boyer79

New member
Joined
Apr 9, 2008
Messages
2
Programming Experience
1-3
hello all -

i'm fairly new to vb.net, so forgive me if this is an easy fix. I have this form that has a button. when clicked it runs the code below to get all the employees in a selected department. all of this works fine. the issue i'm having is that i also have an image (pbProgress) that i need to have visible as that process runs. it starts out set visible = false. while the process is running i'd like it set visible = true. then once the process stops running and populates the field with the employee data, i'd like it set back to visible = false. i've tried setting it in a different class, or in a separate sub, but nothing i've tried has worked. it runs the process, and when it populates the employee data it shows the image. there seems to be no sequential order. please help!

VB.NET:
Private Sub btnEmps_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEmps.Click
        lbxEmps.Items.Clear()
        cmbSupvNew.Text = ""

        Dim i As Integer
        For i = 0 To clbDepts.CheckedItems.Count - 1
            pbProgress.Visible = True
            objEmpList.GetEmpList(i)
            Dim EmpRows() As DataRow, EmpRow As DataRow

            EmpRows = objEmpList.EmpListList.Select()
            If EmpRows.Length = 0 Then
                MsgBox("No Employees Found", MsgBoxStyle.Exclamation, "Alert")
            Else
                For Each EmpRow In EmpRows
                    lbxEmps.Items.Add(EmpRow("empnum").ToString & _
                    " " & EmpRow("empname").ToString)
                Next
            End If
        Next i

    End Sub
 
Add a 'Application.DoEvents' in there:

VB.NET:
Dim i As Integer
        For i = 0 To clbDepts.CheckedItems.Count - 1
            pbProgress.Visible = True
            [B]Application.DoEvents[/B]
            objEmpList.GetEmpList(i)
            Dim EmpRows() As DataRow, EmpRow As DataRow
 
Back
Top