Button bt=new Button()
bt.location={0,0};
bt.width=100;
bt.height
想在鼠标移动到bt时,在bt边界0---20范围内鼠标光标形状变成SizeWE形状,在20----80范围内鼠标光标形状变成SizeAll形状,请高手指点下!!!

解决方案 »

  1.   

    1添加此btn的 MouseMove 事件
    private void button1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    int a=e.X;
    int b=e.Y;
    }
    a b 为鼠标相对btn 位置 剩下的 自己写吧
      

  2.   

    Imagebutton不行吧,我要的时对鼠标的操作
      

  3.   

    button1.Cursor=System.Windows.Forms.Cursors.**;
    对鼠标样式的改变
      

  4.   

    private void button1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Point ptcursor = System.Windows.Forms.Cursor.Position;
    Point ptClient = this.PointToClient(ptcursor);
    int startx = button1.Left;
    int starty = button1.Top;
    Rectangle rect1 = new Rectangle(startx, starty, button1.Width, button1.Height); //da
    Rectangle rect2 = new Rectangle(startx + 20, starty + 20, button1.Width - 40, button1.Height - 40);

    if(rect1.Contains(ptClient) && !rect2.Contains(ptClient))
    {
    this.Cursor = Cursors.SizeWE;
    }
    else if(rect2.Contains(ptClient))
    {
    this.Cursor = Cursors.SizeAll;
    }
    }
      

  5.   

    在button1中激发MouseMove事件
    private void button1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Point ptcursor = System.Windows.Forms.Cursor.Position;
    Point ptClient = this.PointToClient(ptcursor);
    int startx = button1.Left;
    int starty = button1.Top;
    Rectangle rect1 = new Rectangle(startx, starty, button1.Width, button1.Height);
    Rectangle rect2 = new Rectangle(startx + 20, starty + 20, button1.Width - 40, button1.Height - 40);

    if(rect1.Contains(ptClient) && !rect2.Contains(ptClient))
    {
    this.Cursor = Cursors.SizeWE;
    }
    else if(rect2.Contains(ptClient))
    {
    this.Cursor = Cursors.SizeAll;
    }
    }
    然后与在Form1中激发MouseMove事件
    private void _MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
    {
    Point ptcursor = System.Windows.Forms.Cursor.Position;
    Point ptClient = this.PointToClient(ptcursor);
    int startx = button1.Left;
    int starty   = button1.Top;
    Rectangle rect1 = new Rectangle(startx, starty, button1.Width, button1.Height); 
    if(!rect1.Contains(ptClient))
    {
    this.Cursor = Cursors.Hand;
    }
    }
    这样就能解决了,就是土了点