C#中怎么得到1个按钮不在某个位置
来源:百度知道 编辑:UC知道 时间:2024/05/19 20:01:17
C#中怎么得到1个按钮不在某个位置 如确定BUTTON1不在(10,10)
if(this.button1.ClientRectangle.Contains(new Point(10,10))
{
//按钮在(10,10)位置
Button b = (Button)this.GetChildAtPoint(new Point(10,10));
}
用Location判断只能判断,控件的起始点是不是
如果10,10在控件内部,就不能判断了,所以要用上面的俩判断方法
如果是winform程序
if(button1.Location.X != 10||button1.Location.Y != 10)
{
}
这个简单~
if (this.button1.Location.X != 10 && this.button1.Location.Y != 10)
{
button1.Text = "haha";
}
先得到这个按钮的位置座标、高宽,然后跟你要确定的座标对比。起点座标对比,加上高宽后再对比,都不在这个范围就说明这个按钮不在这个位置
什么类型的程序这样判断有点不符合逻辑