代码画线的方法

添加引用:

using System.Drawing;

事件:

private void button1_Click(object sender, EventArgs e)
        {
            Graphics g = this.PICTUREBOX1.CreateGraphics();
            Brush b = new SolidBrush(选择颜色);
            Pen p = new Pen(b);
            g.DrawLine(p, 起点, 终点);
            g.DrawRectangle(p, x坐标, y坐标, 宽, 高);
        }

如果要通过RGB确定颜色,则可以这么写:

Color color = Color.FromArgb(255, 255, 255);

Pen p = new Pen(color);

g.DrawLine(p,起点,终点);

g.DrawRectangle(p,x坐标,y坐标,宽,高);

你可能感兴趣的:(C#,图形处理,C++)