我想得到鼠标点击的图片框的位置,但我不知道怎么做??我的意思是图片框的位置,而不是图片框的形式。谢谢。
问问题
7955 次
2 回答
4
MUGAN 关门了。您将从 MouseEventArgs 获得的 Point 是鼠标的“屏幕”点,其中 0,0 是整个显示器或桌面的左上角(无论您想怎么想)。要将其转换为 PictureBox 控件中的“客户端”点,其中 0,0 是该 PictureBox 的左上角,您需要使用 Control.PointToClient() 方法:
private void pb_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point mouseDownLocation = (Control)sender.PointToClient(new Point(e.X, e.Y));
//here goes your if condition ...
}
于 2011-03-08T17:30:31.790 回答
1
private void pb_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
Point mouseDownLocation = new Point(e.X, e.Y);
//here goes your if condition ...
}
于 2011-03-08T17:25:52.400 回答