实现效果:
知识运用:
Graphics类的DrawRectangle方法
public void DrawRectangle (Pen pen,Rectangel rect) //绘制由Rectangle结构指定的矩形
public void DrawRectangle (Pen pen,int x,int y,int width,int height) //绘制由坐标对 宽度 高度指定的矩形
实现代码:
private void button1_Click(object sender, EventArgs e) { Pen blackPen = new Pen(Color.Red,5); Graphics graphics = this.CreateGraphics(); graphics.DrawRectangle(blackPen,40,30,200,150); }