主要的问题是Graphics的图形看不见,请知道的兄台指点下!单纯的Graphic绘图代码如下: private void DrawGraphic(PaintEventArgs e) { Graphics g = e.Graphics; // Opaque colors (alpha value defaults to 255 -- max value). Color red = Color.FromArgb(255, 0, 0); Color green = Color.FromArgb(0, 255, 0); Color blue = Color.FromArgb(0, 0, 255); // Solid brush initialized to red. SolidBrush myBrush = new SolidBrush(green); int alpha; // x coordinate of first red rectangle int x = 50; // y coordinate of first red rectangle int y = 50; // Fill rectangles with red, varying the alpha value from 25 to 250. for (alpha = 25; alpha <= 250; alpha += 25) { myBrush.Color = red; g.FillRectangle(myBrush, x, y, 50, 100); g.FillRectangle(myBrush, x, y + 250, 50, 50); x += 50; } }
private void DrawGraphic(PaintEventArgs e)
{
Graphics g = e.Graphics; // Opaque colors (alpha value defaults to 255 -- max value).
Color red = Color.FromArgb(255, 0, 0);
Color green = Color.FromArgb(0, 255, 0);
Color blue = Color.FromArgb(0, 0, 255); // Solid brush initialized to red.
SolidBrush myBrush = new SolidBrush(green);
int alpha; // x coordinate of first red rectangle
int x = 50; // y coordinate of first red rectangle
int y = 50; // Fill rectangles with red, varying the alpha value from 25 to 250.
for (alpha = 25; alpha <= 250; alpha += 25)
{
myBrush.Color = red;
g.FillRectangle(myBrush, x, y, 50, 100);
g.FillRectangle(myBrush, x, y + 250, 50, 50);
x += 50;
}
}