ireaper
2011-09-10 00:12 symphony2010 阅读(220) 评论(0) 编辑 收藏 举报继续学习,ireaper,分析RightClickableDataGridView文件,该文件实现以下功能:
* 1. 当多项被选中后,单击某选中项
* 1.1 在MouseUp前,不会刷新选中状态。
* 1.2 在MouseUp前,启动DragDrop后可以对多个选项进行DragDrop操作
* 2. 当使用右键单击某个非选中项时,会首先选中该项,然后再弹出上下文菜单
挨个看看都是怎么实现的:
1,右键实现单击选中当前行,和取消别的行,主要以下代码实现:
else if ((e.Button & MouseButtons.Right) == MouseButtons.Right)
{
this.ClearSelection();
this.SetSelectedRowCore(info.RowIndex, true);
this.ResetMouseEventArgs();
}
其中HitTestInfo info = this.HitTest(e.X, e.Y);在分析。
2,在MouseUp前,启动DragDrop后可以对多个选项进行DragDrop操作
if (this.isDrag && info.RowIndex == this.mouseDownIndex && (e.Button & MouseButtons.Left) == MouseButtons.Left)
{
this.ClearSelection();
this.SetSelectedRowCore(info.RowIndex, true);
}
else
{
base.OnMouseUp(e);
}
this.mouseDownIndex = -1;
DragDrop 又是啥玩意?