1
内的控制我有一个PictureBox
这是一个TabPage
里面,当然这TabPage
是TabView
的一部分,这TabView
是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
事件。只要按下按钮后移动鼠标,图片框就会跳出标签页的可见区域。
我需要知道如何处理移动只在标签页的矩形内,如果图片框被拖出标签视图的可见区域,它不应该再移动,除非用户将鼠标放在标签内视图的可见矩形。
任何帮助/提示将appriciated!
非常感谢!也感谢汉斯! – 2012-08-16 20:29:53