Hi All Masters

This is my Second question and problem ...i have some code here

Sub SetLabels()
Call MySqlConnect()
            Dim str As String
            str = " Select * from room "
            da = New MySqlDataAdapter(str, conn)
            ds = New DataSet
            da.Fill(ds, "room")

            For i = 0 To ds.Tables("room").Rows.Count - 1

                Dim newLabel As New Label
                newLabel.Text = ds.Tables("room").Rows(i)("room_code")
                newLabel.Name = newLabel.Text
                newLabel.BorderStyle = BorderStyle.FixedSingle
                newLabel.Size = New Drawing.Size(100, 100)
                newLabel.Font = New Font("Tahoma", 15, FontStyle.Regular)
                newLabel.TextAlign = ContentAlignment.TopCenter
                newLabel.BackColor = Color.LightSkyBlue

                 If ds.Tables("room").Rows(i)("room_status") = "1" Then
                    newLabel.BackColor = Color.LightGreen
                ElseIf ds.Tables("room").Rows(i)("room_status") = "2" Then
                    newLabel.BackColor = Color.Red
                End If

                Dim labels(i) As Label
                labels(i) = newLabel
                Me.Controls.Add(newLabel)

End Sub()               

I put that code in Form_Load Event by Call SetLabels()...now my question is how to refresh labels for 5 Seconds with timer control if column "rooms_status" have a value or change value....

or my code has something wrong ....?

Please an advice or sample code for me....im newbie for this

Ps: I'm Using Visual Studio 2010 Express

In advance, thanks for any help.

Regards

Edited 1 Year Ago by Imam_3: edited

Refreshing on every 5 seconds directly by using timer can make a problem on objects focus on user's screen and it is most disturbing probling at the time of dataentry. To avoide this type of problem you can use BackgroundWorker.
Here is a fine tutorial about BackgroundWorker created by Rev. Jim which can make solution of your problem.

hi shark_1

oke i'll try your referrence...thanks before

regards

@shark 1

sorry i'm still confused for this...i've tried that tutorial, but i still dont understand that tutorial...:(

can you help me please...? :)

in advance ..thank for your help

regards...:)

This article has been dead for over six months. Start a new discussion instead.