我有 aPictureBox在 a 内TabPage,当然这TabPage是 a 的一部分,TabView这TabView是在 a 内Form。我希望用户能够在标签页中移动这个图片框。为此,我使用图片框的MouseDown,MouseMove和MouseUp事件:
private void pictureBoxPackageView_MouseDown(object sender, MouseEventArgs e)
{
if (!_mapPackageIsMoving)
{
_mapPackageIsMoving = true;
}
}
private void pictureBoxPackageView_MouseMove(object sender, MouseEventArgs e)
{
if(_mapPackageIsMoving)
{
pictureBoxPackageView.Location = MousePosition; //This is not exact at all!
return;
}
//Some other code for some other stuff when picturebox is not moving...
}
private void pictureBoxPackageView_MouseUp(object sender, MouseEventArgs e)
{
if (_mapPackageIsMoving)
{
_mapPackageIsMoving = false; //Mouse button is up, end moving!
return;
}
}
但我的问题在于MouseMove事件。按下按钮后,只要我移动鼠标,图片框就会跳出标签页的可见区域。
我需要知道如何仅在选项卡页的矩形内处理移动,如果图片框被拖出选项卡视图的可见区域,除非用户将鼠标移到选项卡视图的可见矩形内,否则它不应再移动。
任何帮助/提示将被应用!