using a timer, how do I code the background color for my group boxes to flash from one color to the next until a condition is met? (mainly, I just need help getting the colors alternating, I have the code to check the condition)
Thanks!!
Printable View
using a timer, how do I code the background color for my group boxes to flash from one color to the next until a condition is met? (mainly, I just need help getting the colors alternating, I have the code to check the condition)
Thanks!!
I figured this much out. It works exactly like I want.
Can anyone think of a better, more efficient way of coding this?
Code:Private Sub tmrGrpCurrentOpen_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrGrpCurrentOpen.Tick
If grpCurrentOpen.BackColor.Equals(AliceBlue) Then
grpCurrentOpen.BackColor = Red
Else
grpCurrentOpen.BackColor = AliceBlue
End If
End Sub
I don't think this is better, but it's different. It might be useful depending on what else is going on in your application.
On balance, I think you should stick with what you've got.
VB Code:
Private tmr As New Timer() Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load AddHandler Application.Idle, AddressOf Flash tmr.Interval = 1000 tmr.Start() End Sub Private Sub Flash(ByVal sender As Object, ByVal e As System.EventArgs) If Now.Second Mod 2 = 0 Then grpCurrentOpen.BackColor = Color.Red Else grpCurrentOpen.BackColor = Color.AliceBlue End If End Sub