public partial class Form1 : Form
{
bool MouseIsDown = false;
Rectangle MouseRect = Rectangle.Empty;
public Form1()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(Form1_MouseDown);
this.MouseMove += new MouseEventHandler(Form1_MouseMove);
this.MouseUp += new MouseEventHandler(Form1_MouseUp);
}
void Form1_MouseDown(object sender, MouseEventArgs e)= true;
DrawStart(e.Location);
}
void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (MouseIsDown)
{
ResizeToRectangle(e.Location);
}
//这里可以实现选中啊,但是必须要鼠标在子控件上活动过(鼠标路过子控件)才能选中
//Control ctl = this.GetChildAtPoint(e.Location);
//if (ctl != null)
//{
// ctl.BackColor = Color.Blue;
//}
}
void Form1_MouseUp(object sender, MouseEventArgs
C# Winform 窗体用鼠标拖出虚线框....并且虚线框区域里的所有控件选中
最新推荐文章于 2024-08-05 10:53:55 发布
这个博客介绍了如何在C#的Winform应用中实现使用鼠标拖动绘制虚线框,并在虚线框区域内批量选择控件。通过监听MouseDown, MouseMove和MouseUp事件,动态更新虚线框大小并在MouseUp事件中判断控件是否位于虚线框内,从而实现选中效果。"
129645976,11093367,GEE深度解析:ee.image.cumulativeCost多波段处理,"['GIS', '遥感', '地球科学', '图像处理', 'JavaScript API']
摘要由CSDN通过智能技术生成