我现在得到了一个鼠标的MouseRect范围。我想每次在我按下ctrl键的时候,都得到另一个MouseRect范围(就是将每次按住ctrl键的都保存下来),最后在鼠标MouseUp的时候来出得到的这个MuseRect集合。 

解决方案 »

  1.   

    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 
      

  2.   

    判断Keys.Control谢谢楼上。
    现在的问题是在我第二次鼠标MousDown的时候,前面一次lastRect范围内选中的效果已经没有了。我想当我按住ctrl的时候,每一次拖选的效果都在。就像treeList里面,点一行时选中这一行,按住ctrl的时候,就多选行在key_down事件里面应该如何处理才好呢?