我想知道被鼠标点击的图片框的位置,但我不知道怎么做??
我的意思是画板的位置,而不是画板的形状。
谢谢。

最佳答案

穆根就在附近。从mouseeventargs得到的点是鼠标的“屏幕”点,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 ...
}

关于c# - 获取已单击的图片框的位置,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5235967/

10-12 12:53