if (Cursor.Position == closeButton.Location)
{
closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);
}
这个 if 语句由于某种原因不起作用,有什么帮助吗?
我想检查光标位置是否在位置集中。
最佳答案
您需要检查 ClientRectangle
你的按钮的属性。所以这是要使用的正确语法:
if (closeButton.ClientRectangle.Contains(closeButton.PointToClient(Cursor.Position)))
{
closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);
}
关于c# - 如果光标在位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50653761/