写个了控件,在里面需要在鼠标移动时显示相关内容,于是定义了一个picturebox 设定picturebox.location=new point(e.x,e.y)可是显示时,picturebox显示在鼠标上方,鼠标在其下边的中间位置

解决方案 »

  1.   

    你要看那个e是谁发出来了,e.X和e.Y用的是事件发起者的坐标。比如:void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        Point locationInScreen = (sender as PictureBox).PointToScreen(e.Location);
        Point locationInParent = (sender as PictureBox).Parent.PointToClient(locationInScreen);    (sender as PictureBox).Location = locationInParent;
    }