Winform 怎么实现床体上的鼠标拉选 比如 我们window 桌面,按住鼠标左键不放,然后移动鼠标就会出现一个 虚框,被框到 这个虚框中的 图标和文件就 反蓝表示选中 我想要这个效果,不知道用Winform 怎么做!求各位大侠帮忙 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mousedown 的时候 取坐标 mousemove 的时候 再取坐标 2个点做对角 画矩形选中就用这个矩形和其他控件来hittest 看有没重叠部分 你是要做虚框还是拉框选择,拉框选择文件你用ListView 中小企业ERP一般是C#,VB,稍大一点企业用JAVA 不是拉框选文件,是虚框!我的form 上有 三个button ,然后我拉选的时候 出现一个虚框,能在移动中将这三个button 圈到虚框中的这种效果! ListView 是圈选列表吧 我要的是圈选 form窗体上的控件! mousedownmousemove 大概用这2个 来取坐标。 找到方法了!谢谢大家!给大家一个源码吧!public partial class Form2 : Form { bool MouseIsDown = false; Rectangle MouseRect = Rectangle.Empty; public Form2() { InitializeComponent(); this.MouseDown += new MouseEventHandler(frmMain_MouseDown); this.MouseMove += new MouseEventHandler(frmMain_MouseMove); this.MouseUp += new MouseEventHandler(frmMain_MouseUp); } void frmMain_MouseUp(object sender, MouseEventArgs e) { this.Capture = false; Cursor.Clip = Rectangle.Empty; MouseIsDown = false; DrawRectangle(); MouseRect = Rectangle.Empty; } void frmMain_MouseMove(object sender, MouseEventArgs e) { if (MouseIsDown) ResizeToRectangle(e.Location); } void frmMain_MouseDown(object sender, MouseEventArgs e) { MouseIsDown = true; DrawStart(e.Location); } private void ResizeToRectangle(Point p) { DrawRectangle(); MouseRect.Width = p.X - MouseRect.Left; MouseRect.Height = p.Y - MouseRect.Top; DrawRectangle(); } private void DrawRectangle() { Rectangle rect = this.RectangleToScreen(MouseRect); ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed); } private void DrawStart(Point StartPoint) { this.Capture = true; Cursor.Clip = this.RectangleToScreen(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height)); MouseRect = new Rectangle(StartPoint.X, StartPoint.Y, 0, 0); } } 遇见了个纠结的问题,求高手解答 隐藏树节点,或禁用树节点 winform 请教关于一些收费控件的问题? keyDown事件捕捉不到方向键的问题? 关于启动窗口的问题 Format 使构造函数构造对象失败 讨论抽象和控制点移动 在winform中怎么使用Infragistics.Win.UltraWinSchedule.v3.2.dll 嗯,好吧,问问关于Windows集成验证 请问怎么转换win32_process中的属性creationDate为c#中的datetime类型 clickonce 清单签名证书延长有效期 的参数设置问题
mousemove 的时候 再取坐标 2个点做对角 画矩形
选中就用这个矩形和其他控件来hittest 看有没重叠部分
不是拉框选文件,是虚框!
我的form 上有 三个button ,然后我拉选的时候 出现一个虚框,能在移动中将这三个button 圈到虚框中的这种效果!
mousemove 大概用这2个 来取坐标。
{
bool MouseIsDown = false;
Rectangle MouseRect = Rectangle.Empty;
public Form2()
{
InitializeComponent();
this.MouseDown += new MouseEventHandler(frmMain_MouseDown);
this.MouseMove += new MouseEventHandler(frmMain_MouseMove);
this.MouseUp += new MouseEventHandler(frmMain_MouseUp);
} void frmMain_MouseUp(object sender, MouseEventArgs e)
{
this.Capture = false;
Cursor.Clip = Rectangle.Empty;
MouseIsDown = false;
DrawRectangle();
MouseRect = Rectangle.Empty;
}
void frmMain_MouseMove(object sender, MouseEventArgs e)
{
if (MouseIsDown)
ResizeToRectangle(e.Location);
}
void frmMain_MouseDown(object sender, MouseEventArgs e)
{
MouseIsDown = true;
DrawStart(e.Location);
}
private void ResizeToRectangle(Point p)
{
DrawRectangle();
MouseRect.Width = p.X - MouseRect.Left;
MouseRect.Height = p.Y - MouseRect.Top;
DrawRectangle();
}
private void DrawRectangle()
{
Rectangle rect = this.RectangleToScreen(MouseRect);
ControlPaint.DrawReversibleFrame(rect, Color.White, FrameStyle.Dashed);
}
private void DrawStart(Point StartPoint)
{
this.Capture = true;
Cursor.Clip = this.RectangleToScreen(new Rectangle(0, 0, ClientSize.Width, ClientSize.Height));
MouseRect = new Rectangle(StartPoint.X, StartPoint.Y, 0, 0);
}
}