我在winforms上有一个datagridview控件,带有以下事件将“行”拖出数据网格:
private void gridOperations_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
if (Math.Abs(e.X - mouseDownPos.X) >= SystemInformation.DoubleClickSize.Width || Math.Abs(e.Y - mouseDownPos.Y) >= SystemInformation.DoubleClickSize.Height)
{
string[] filesToDrag = { "tmp/generated.log" };
gridOperations.DoDragDrop(new DataObject(DataFormats.FileDrop, filesToDrag), DragDropEffects.Copy);
}
}
}
问题是我在 datagridview 上也有单击和双击事件,双击事件几乎一开始就不会执行,除非我在单击时根本不移动鼠标。我怎样才能添加一个'thershold',这样如果我按住鼠标并拖动单元格3个像素,那么它将触发gridOperations.DoDragDrop?谢谢!