c# - Change button color for a short time -


i change backgroundcolor of button couple of seconds lime , change normal. reason doesnt work, have wait seconds , things tested work backgroundcolor isn't changed. i've tried far:

private void button1_click(object sender, eventargs e) {     button1.backcolor = color.lime;     thread.sleep(2000);     button1.backcolor = systemcolors.control; } 

hopefully can me out this!

you need timer. add timer control toolbox form. double-click on add timer tick event handler

    private void button1_click(object sender, eventargs e)     {         button1.backcolor = color.lime;         //set time between ticks in miliseconds.         timer1.tick=2000;         //start timer, program continues execution normaly         timer1.start;         //if use sleep(2000) program stop working 2 seconds.      }         //this event rise every time set in tick (from start stop)         private void timer1_tick(object sender, eventargs e)         {           //when execution reach here, means 2 seconds have passed. stop timer , change color           timer1.stop;           button1.backcolor = systemcolors.control;         } 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -