{
Graphics g=this. CreateGraphics ();
Pen p=new Pen (Color. Gray, 1);
The switch (I)
{
Case 0:
SolidBrush b=new SolidBrush (Color Black);
G.F illEllipse (b, + 70 x, y, 20, 20).
G.F illEllipse (b, + 90 x, y, 20, 20).
break;
Case 1:
SolidBrush b1=new SolidBrush (Color. Green);
G.F illEllipse (b1, + 90 x, y, 20, 20).
break;
Case 2:
SolidBrush b2=new SolidBrush (Color Red);
G.F illEllipse (b2, + 70 x, y, 20, 20).
break;
Default: break;
}
}
Private void Form1_Paint (object sender, PaintEventArgs e)
{
A (200, 166, 0);
}
Private void button8_Click (object sender, EventArgs e)
{
A (200, 166, 1);
}
Why did not achieve the function of the ah, click the button to appear green, but move the mouse did not have, have a great god can solve?
CodePudding user response:

CodePudding user response:
Have to be like this? Is a function of several such I just wrote a I realize in this is a few lights, press the corresponding button corresponding lights turned align road station (simulated), if so write, if only a few variables, a few light followed changed it,CodePudding user response:
Before you write a function in the in the paint and the respective button just so why ah?CodePudding user response:
Because of a Paint event triggerCodePudding user response:
Don't write a function before how can?