private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            if (isMouseDown == true)
            {                P2.X = e.X;
                P2.Y = e.Y;
                DrawTY(this.CreateGraphics(), P2.X, P2.Y, 100, 100);
                this.Invalidate();
            }
        }修改了下你的代码,在MouseMove中加入了Move的事件,这样才能看到圆,当然在窗体重绘过程中就有消失了,所以是闪烁的,但是并没有出现你所说的问题

解决方案 »

  1.   

     public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        Point P1 = new Point();
            Point P2 = new Point();
            bool isMouseDown = false;        private void Form1_MouseUp(object sender, MouseEventArgs e)
            {
                isMouseDown = false;
                
            }        private void Form1_Load(object sender, EventArgs e)
            {
                
            }        private void Form1_Paint(object sender, PaintEventArgs e)
            {
                
                Graphics g = e.Graphics;        //    g.DrawEllipse(new Pen(Color.Red, 3), 1, 1, 5, 5);
                g.DrawRectangle(new Pen(Color.Blue, 3), P1.X > P2.X ? P2.X : P1.X, P1.Y > P2.Y ? P2.Y : P1.Y, Math.Abs(P2.X - P1.X), Math.Abs(P2.Y - P1.Y));            
            }                private void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                if (isMouseDown == false)
                {
                    isMouseDown = true;                P1.X = e.X;
                    P1.Y = e.Y;
                }
            }        private void Form1_MouseMove(object sender, MouseEventArgs e)
            {
                if (isMouseDown == true)
                {                P2.X = e.X;
                    P2.Y = e.Y;                this.Invalidate();
                }
            }
        }谢谢上面的同学,但是还有问题。
    大家看我上面那一行代码,可以实现矩形的。