Results 1 to 3 of 3

Thread: making backcolor switch back and forth[RESOLVED]

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    making backcolor switch back and forth[RESOLVED]

    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!!
    Last edited by Andy; Feb 11th, 2004 at 09:44 PM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    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

  3. #3
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    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:
    1. Private tmr As New Timer()
    2.  
    3.     Private Sub Form1_Load(ByVal sender As System.Object, _
    4.                            ByVal e As System.EventArgs) Handles MyBase.Load
    5.         AddHandler Application.Idle, AddressOf Flash
    6.         tmr.Interval = 1000
    7.         tmr.Start()
    8.     End Sub
    9.  
    10.     Private Sub Flash(ByVal sender As Object, ByVal e As System.EventArgs)
    11.         If Now.Second Mod 2 = 0 Then
    12.             grpCurrentOpen.BackColor = Color.Red
    13.         Else
    14.             grpCurrentOpen.BackColor = Color.AliceBlue
    15.         End If
    16.     End Sub
    This world is not my home. I'm just passing through.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width