如何使矩形可点击,C# [英] How can I make the rectangles clickable, C#

查看:249
本文介绍了如何使矩形可点击,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码可以在运行时生成矩形(Rectangle矩形).矩形的位置可能会根据用户的选择而变化.

The code can generate rectangles (Rectangle rectangle) at runtime. The position of rectangles may change according to users' choices.

我想在创建矩形以使矩形可点击的方法中添加代码.用户单击矩形后,将出现一个新窗口,以显示与文本一样的内容.

I want to add code in the method where it creates rectangles to make the rectangles clickable. And after user clicking the rectangle, there will be a new window to show content just like text.

推荐答案

您可以使用Rectangle对象的Contains方法.

You can use Contains method of the Rectangle object.

private Rectangle _myRectangle;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
    if (this._myRectangle.Contains(e.Location))
    {

    }
}

这篇关于如何使矩形可点击,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆