欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Winform中GDI+绘图(椭圆,直线等)

程序员文章站 2022-03-31 19:52:22
...

用 CreateGraphics 方法创建 Graphics 对象

Graphics g = this.CreateGraphics();  

画线,下例是一个棋盘:

            //x+=15每一个格子的宽15,y+=15每一个格子的高15  
            for (int x = 10, y = 10, count = 0; count < 15; x += 15, y += 15, count++)  
            {  
                //220=15*14+10(格子宽*14+期盼最左的线起始x坐标)  
                g.DrawLine(new Pen(Color.Blue), new Point(10, y), new Point(220, y));  
                g.DrawLine(new Pen(Color.Blue), new Point(x, 10), new Point(x, 220));  
  
            }

画椭圆:

g.FillEllipse(Brushes.Black,rtg);

  

转载于:https://www.cnblogs.com/fornet/archive/2013/03/22/2976300.html