Making a control flash

  • Thread starter Thread starter Mystery Man
  • Start date Start date
M

Mystery Man

I want to deliberately make a label (and perhaps a button) flash to
alert the user that something very serious has happened.

Any ideas on how to do this?
 
without stating my opinion on blinking things in a UI...

Add a timer control to your form and then whenever you want it to start
blinking, set it's enabled property to true. In the timer's tick event, set
it to visible if visible is false and set visible to false if it's true.
You can use a Static module level variable and just set the visible property
to the boolean variable....and just change the bool's value with each tick.

HTH,

Bill
 
I'd recommend rather than toggling the visibility, toggling the enabled state,
that way it flashes from black to gray to black, similar effect, but the text
is always visible.

No need to store the state separately, just use the following:

label.Enabled = !label.Enabled;

in response to the timer event.
 
Bret:

Good points, and yes, there are multiple properties that you can manipulate
to create a blinking effect. Personally, I tend to use the approach you
mention setting the property to it's opposite when state can only be one of
two conditions. However, I have run into occassions where the behavior
might need to be temporarily changed and other properties may need to be
changed based on that change, hence the module level variable. I think for
this issue though, your approach is definitely cleaner.

Cheers,

Bill
 
If that serious thing is some erroneous input use the Error provider class
that is the standard way of doing making a alert.

Nirosh.
 
Back
Top