我想在c#中画图,程序如下
for (int i = 110; i <= 170; i += 20) { Graphics g = e.Graphics; Pen pen = new Pen(Color.Black, 5); g.DrawRectangle(pen, 55, i, 220, 20); g.DrawRectangle(pen, 385, i, 220, 20); g.DrawRectangle(pen, 715, i, 220, 20); SolidBrush brush = new SolidBrush(Color.Red); g.FillRectangle(brush, 55, i, 220, 20); g.FillRectangle(brush, 385, i, 220, 20); g.FillRectangle(brush, 715, i, 220, 20); } for (int i = 190; i <= 250; i += 20) { Graphics g = e.Graphics; Pen pen = new Pen(Color.Black, 5); g.DrawRectangle(pen, 55, i, 220, 20); g.DrawRectangle(pen, 385, i, 220, 20); g.DrawRectangle(pen, 715, i, 220, 20); SolidBrush brush = new SolidBrush(Color.Orange); g.FillRectangle(brush, 55, i, 220, 20); g.FillRectangle(brush, 385, i, 220, 20); g.FillRectangle(brush, 715, i, 220, 20); } for (int i = 270; i <= 330; i += 20) { Graphics g = e.Graphics; Pen pen = new Pen(Color.Black, 5); g.DrawRectangle(pen, 55, i, 220, 20); g.DrawRectangle(pen, 385, i, 220, 20); g.DrawRectangle(pen, 715, i, 220, 20); SolidBrush brush = new SolidBrush(Color.Yellow); g.FillRectangle(brush, 55, i, 220, 20); g.FillRectangle(brush, 385, i, 220, 20); g.FillRectangle(brush, 715, i, 220, 20); }
画完是3列矩形,想通过链表实现如下功能:能够自由拖拽各个小矩形,实现每列前后可以自由插入比如将第一列5号插入到2号前,列之间可以自由插入,比如将第一列的2号插入到第二列的2号前,怎么编程呀~~~小弟刚学c#不久,对链表不太明白,最好有注释,代码发到邮箱windyk508@163.com,谢谢啦~~
1.方形。
private void Form1_Paint(object sender, PaintEventArgs e) { System.Drawing.Graphics graphicsObj; graphicsObj = this.CreateGraphics(); Pen myPen = new Pen(System.Drawing.Color.Red, 5); Rectangle myRectangle = new Rectangle(20, 20, 250, 200); graphicsObj.DrawRectangle(myPen, myRectangle); }
2.圆形。
private void Form1_Paint(object sender, PaintEventArgs e) { System.Drawing.Graphics graphicsObj; graphicsObj = this.CreateGraphics(); Pen myPen = new Pen(System.Drawing.Color.Green, 5); Rectangle myRectangle = new Rectangle(20, 20, 250, 200); graphicsObj.DrawEllipse(myPen, myRectangle); }
panel控件也好使吗?
@巴索罗缪库玛: 可以啊。
@荒野的呼唤: 就把form_paint换成panel_paint就可以了吧
@荒野的呼唤: 不好使呀~~能把完整的程序发到我邮箱吗?谢谢啊~~