我在窗体上添加了一个面板,当我点击button时让鼠标只能在面板范围内移动

解决方案 »

  1.   

    窗体或者控件都有MOUSE事件. 在里面算他的范围啊
      

  2.   

    Cursor.Clip
    void button1_Click(object sender, EventArgs e)
    {
        Rectangle clipRectangle = this.panel1.RectangleToScreen( this.panel1.ClientRectangle );
        System.Windows.Forms.Cursor.Clip = clipRectangle;
    }
      

  3.   

    不错,要解除的话,
    Rectang r=new  Rectange(Screen[0].Width,*.Heigth);
    Cursor.Clip=r;
      

  4.   

    void button1_Click(object sender, EventArgs e)
    {
        Rectangle clipRectangle = this.panel1.RectangleToScreen( this.panel1.ClientRectangle );
        System.Windows.Forms.Cursor.Clip = clipRectangle;
    }不错,要解除的话, 
    Rectang r=new  Rectange(Screen[0].Width,*.Heigth); 
    Cursor.Clip=r;纯粹!
      

  5.   

     Cursor.Clip = panel1.RectangleToScreen(panel1.ClientRectangle);//锁定
    Cursor.Clip = Rectangle.Empty;//解锁
    感谢各位了 
      

  6.   

     Point aa = new Point();
                Rectangle rect;
                if (e.Button == MouseButtons.Left && aaa)
                {                aa.X = cInterface.iPanelAMinSize;
                    aa.Y = 0;
                    rect = new Rectangle(aa, new Size(cInterface.iPanelAMaxSize, this.Height));
                }
                else
                {
                    aa.X = 0;
                    aa.Y = 0;
                   rect = new Rectangle(aa, new Size(9999, 9999));
                }
                System.Windows.Forms.Cursor.Clip = rect;