1
我有與下列事件的WinForms DataGridView控件拖動「行」出來的DataGrid:的DataGridView CellDrag太敏感
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?謝謝!
非常感謝,完美的工作! – Kristian 2013-02-11 12:02:28