if (Cursor.Position == closeButton.Location){ closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);}這個 if 語句由于某種原因不起作用,有什么幫助嗎?我希望它檢查光標(biāo)位置是否在位置集中。
1 回答

慕沐林林
TA貢獻2016條經(jīng)驗 獲得超9個贊
您需要檢查ClientRectangle按鈕的屬性。所以這是使用的正確語法:
if (closeButton.ClientRectangle.Contains(closeButton.PointToClient(Cursor.Position)))
{
closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);
}
- 1 回答
- 0 關(guān)注
- 186 瀏覽
添加回答
舉報
0/150
提交
取消