Question using progressbar

Joined
Mar 25, 2009
Messages
23
Programming Experience
Beginner
hello

i build a form to do a search in a database

this form contains a progressbar with visible=false

if the user clicks the search button :
1- the progressbar should be visible
2- do the search
3- put the results counter in a label
4- the progressbar should be inVegetable (invisible)

I use this code
VB.NET:
ProgressBar1.Visible = True
        Dim SQLString As String
        SQLString = ConstrutctSQL()
        Dim myConn As New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\GS\GS\GDB.mdb")
        myConn.Open()
        Dim myComm As New System.Data.OleDb.OleDbCommand(SQLString, myConn)
        Dim dr As System.Data.OleDb.OleDbDataReader
        dr = myComm.ExecuteReader
        dr.Read()
        Label1.Text = dr.Item("numOfCases")
        Label3.Tag = SQLString
        Panel7.Visible = True
        System.Threading.Thread.Sleep(5000)

        ProgressBar1.Visible = False

but the progressbar do not appear while searching, while everything else is going fine
 
Why are you having the thread stop for 5000ms?

Also, use a backgroundworker class. Its simple to report progress that way. The reason nothing is showing is because your programs' GUI thread is being utilized by the calls you're doing. If you make the code work in a BGW class, the program won't freeze up and you can have your progress bar work.
 
Back
Top