G
giannis
How can i make a blinking label ? Is this possible ?
How can i make a blinking label ? Is this possible ?
Never tried this, but you could have a timer, and for each tick event,
change the visibility (or colour, or whatever) of the label in
question.
Herfried said:This should work. For Windows Forms applications,
'System.Windows.Forms.Timer' (available in the toolbox) is the right
choice.
giannis said:I wrote at the Tick event the :
Me.Label.Visible = Not Me.Label.Visible
but nothing happened
Is the line executed? Did you start the Timer (calling start method or
setting enabled=true)? Do you execute other code while you expect the
Timer to tick? If you do, the Timer won't tick before the code has
finished it's job. To solve it, execute the other code in another
thread. This prevents the main thread that also keeps the Timer ticking,
from being blocked by the other code.
giannis said:the form2 have a label "please wait" that i want to blink. at the
load event of form1 i have write :
My.Forms.form2.Show()
form2.Refresh()
My.Forms.form2.Timer1.Start()
Me.TABLETableAdapter.Fill(Me.DATABASEDataSet.SKITSA)
My.Forms.parakalw.Close()
but the label at the form2 dont blinking
Armin said:See my explanation in my previous post. I also mentioned how to solve it.
giannis said:At your previous post you say :
"execute the other code in another thread".
What means this ? Sorry but i am a newbie user
of Visual Studio and i dont know very well english...
giannis said:The form2 have the label "please wait" and at the load event of
form1 i write :
Dim t As New System.Threading.Thread(AddressOf mySub)
t.Start()
Call mySub()
Me.TABLETableAdapter.Fill(Me.DATABASEDataSet.TABLE)
Form2.Close()
t.Abort()
where :
Sub mySub()
Form2.Show()
Form2.Refresh()
End Sub
but again the label dont blinking ...
Where is the logical error ?
Armin said:Though... First, the timer must be started in the same thread that created
the window containing the label.
Second, you need a message loop in the thread
you started. Call "Application.Run(Form2)" after showing the form.
Otherwise the thread terminates when the end of the thread's main
procedure (sub mysub) is reached, implicitly destroying the forms
created within.
giannis said:The form2 have the label "please wait" and at the load event of
form1 i write :
Dim t As New System.Threading.Thread(AddressOf mySub)
t.Start()
Call mySub()
giannis said:Armin Zingler thank you very mutch for your helping
understand threads.
Now the blinking label works :
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim t As New System.Threading.Thread(AddressOf mySub)
t.Start()
Me.TABLETableAdapter.Fill(Me.DATABASEDataSet.TABLE)
Form2.Close()
t.Abort()
End Sub
Sub mySub()
Form2.Show()
Form2.Refresh()
Form2.Timer1.Start()
Application.Run(Form2) ' or Application.Run() without the Form2
End Sub