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 窗体用鼠标拖出虚线框....并且虚线框区域里的所有控件选中
最新推荐文章于 2025-05-25 21:50:24 发布