2010-06-26 6 views
0

& 끌어서 놓기를 DataGridView에 추가 한 후 CellDoubleClick 이벤트가 작동을 멈췄습니다. CellMouseDown 이벤트에 다음 코드가 있습니다.DragDrop 추가 후 CellDoubleClick 이벤트가 작동하지 않습니다.

private void dataGridView2_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) 
{ 
    var obj = dataGridView2.CurrentRow.DataBoundItem; 
    DoDragDrop(obj, DragDropEffects.Link); 
} 

CellDoubleClick 이벤트를 사용하려면 어떻게 수정해야합니까?

답변

2

예, 작동하지 않습니다. DoDragDrop()을 호출하면 마우스 컨트롤이 Windows D + D 로직으로 바뀌어 정상적인 마우스 처리를 방해합니다. 사용자가 실제로 끌 때까지 D + D 시작을 지연해야합니다. 이 문제를 해결해야합니다.

Point dragStart; 

    private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { 
     if (e.Button == MouseButtons.Left) dragStart = e.Location; 
    } 

    private void dataGridView1_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e) { 
     if (e.Button == MouseButtons.Left) { 
      var min = SystemInformation.DoubleClickSize; 
      if (Math.Abs(e.X - dragStart.X) >= min.Width || 
       Math.Abs(e.Y - dragStart.Y) >= min.Height) { 
       // Call DoDragDrop 
       //... 
      } 
     } 
    } 
+0

고마워요! 잘 작동합니다. – Max

관련 문제