关于用ctrl键时 创建多个Rectangle 我现在得到了一个鼠标的MouseRect范围。我想每次在我按下ctrl键的时候,都得到另一个MouseRect范围(就是将每次按住ctrl键的都保存下来),最后在鼠标MouseUp的时候来出得到的这个MuseRect集合。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Point startPoint; Rectangle lastRect; bool isDragging; protected override void OnMouseDown(MouseEventArgs e) { startPoint = this.PointToScreen(e.Location); lastRect = new Rectangle(0, 0, 0, 0); isDragging = true; } protected override void OnMouseMove(MouseEventArgs e) { if (isDragging ) { Point current = this.PointToScreen(e.Location); int width = current.X - startPoint.X; int height = current.Y - startPoint.Y; ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed); lastRect = new Rectangle(startPoint, new Size(width, height)); ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed); } } protected override void OnMouseUp(MouseEventArgs e) { if (isDragging) { isDragging = false; ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed); } }判断Keys.Control 判断Keys.Control谢谢楼上。现在的问题是在我第二次鼠标MousDown的时候,前面一次lastRect范围内选中的效果已经没有了。我想当我按住ctrl的时候,每一次拖选的效果都在。就像treeList里面,点一行时选中这一行,按住ctrl的时候,就多选行在key_down事件里面应该如何处理才好呢? 怎么得到一个url的地址? 关于使用约束的泛型接口的继承问题 socket循环读出来的byte[]怎么组合到一起? 怎么能重绘窗体的标题栏? 新手关于Dataview,可以从多个表中创建? 各位大哥有几个错误,请各位大哥更正更正。 大家帮我看看,数据库的问题?? 有关C#的票据套打问题,请高手指教 请前辈们指教,现在要怎么提高呢 求救:socket异步,通信到一半时,发生异常:System.Net.Sockets.SocketException (0x80004005): c#与C++与VB.NET 与POWERBUILDER哪个好 是不是哪没设置好?
Rectangle lastRect;
bool isDragging;
protected override void OnMouseDown(MouseEventArgs e)
{
startPoint = this.PointToScreen(e.Location);
lastRect = new Rectangle(0, 0, 0, 0);
isDragging = true;
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (isDragging )
{
Point current = this.PointToScreen(e.Location);
int width = current.X - startPoint.X;
int height = current.Y - startPoint.Y; ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed);
lastRect = new Rectangle(startPoint, new Size(width, height));
ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed);
}
}
protected override void OnMouseUp(MouseEventArgs e)
{
if (isDragging)
{
isDragging = false;
ControlPaint.DrawReversibleFrame(lastRect, this.BackColor, FrameStyle.Dashed);
}
}
判断Keys.Control
现在的问题是在我第二次鼠标MousDown的时候,前面一次lastRect范围内选中的效果已经没有了。我想当我按住ctrl的时候,每一次拖选的效果都在。就像treeList里面,点一行时选中这一行,按住ctrl的时候,就多选行在key_down事件里面应该如何处理才好呢?