A little problem
-
hi,
for(i=0;i<4;i++) { if(i==0){button.Color=Color.Red;} else if(i==1){button.Color=Color.Blue;} else if(i==2){button.Color=Color.Black;}} else if(i==3){button.Color=Color.Yellow;}} }
why button color is not change?i want change the button color according to the if-else conditions.I AM WORKING ON "PLOTTER ROBOT"(FYP).
-
hi,
for(i=0;i<4;i++) { if(i==0){button.Color=Color.Red;} else if(i==1){button.Color=Color.Blue;} else if(i==2){button.Color=Color.Black;}} else if(i==3){button.Color=Color.Yellow;}} }
why button color is not change?i want change the button color according to the if-else conditions.I AM WORKING ON "PLOTTER ROBOT"(FYP).
Each color change causes a message that will be send to the button so that it will change it's color. The messages are queued and are all executed when you return the control to the message pump (when you exit the method). You can use the DoEvents method to make the message pump handle the messages, and a delay so that you have time to actually see the change: foreach (Color c in new Color[] { Color.Red, Color.Blue, Color.Black, Color.Yellow}) { button.Color = c; DoEvents(); Thread.Sleep(500); } However, if you really want to do something like this, you should use a timer instead.
Experience is the sum of all the mistakes you have done.
-
hi,
for(i=0;i<4;i++) { if(i==0){button.Color=Color.Red;} else if(i==1){button.Color=Color.Blue;} else if(i==2){button.Color=Color.Black;}} else if(i==3){button.Color=Color.Yellow;}} }
why button color is not change?i want change the button color according to the if-else conditions.I AM WORKING ON "PLOTTER ROBOT"(FYP).
That'll just make your button yellow every time. Get rid of the for statement.