检查特定区域中的按钮

时间:2015-03-18 20:52:55

标签: c# winforms

如何检查按钮位于特定区域,我有两个按钮,用户用鼠标绘制一个矩形。 如果位置为真,如何检查按钮是否位于矩形区域以进行操作? 这个来自Winform的图像在制作一个矩形时包含我的按钮,我想在找到位于矩形区域的按钮时进行操作 This image from my Winform when make an rectangle contain my buttons, I want when find the buttons located in the rectangle area make an action

1 个答案:

答案 0 :(得分:2)

只需使用Contains Method,就像这样:

if (_yourSelectionRectangle.Contains(new Rectangle(button4.Location, button4.Size))
{
    ...
}
相关问题