十字光标定位

实现效果:

  

知识运用:

  Graphics对象的DrawLine方法

  public void DrawLine (Pen pen, Point pt1,Point pt2)

  public void DrawLine (Pen pen, int x1,int y1,int x2,int y2)

实现代码:

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            Graphics g = this.CreateGraphics();
            g.DrawLine(new Pen(Color.Black,2),new Point(0,e.Y),new Point(this.Width,e.Y));
            g.DrawLine(new Pen(Color.Black, 2), new Point(e.X, 0), new Point(e.X,this.Height));
        }

 

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10274393.html