控制拖放

时间:2011-07-22 15:14:22

标签: c# winforms drag-and-drop controls

我在Windows窗口的c#中有一个用户控件,拖放事件只是在控件的边缘触发,有没有人知道是什么导致它让我疯了!?

private void flowDiagram1_DragEnter(object sender, DragEventArgs e)
{
  if(e.Data.GetDataPresent(DataFormats.Text))
    e.Effect = DragDropEffects.Move;
  else
    e.Effect = DragDropEffects.None;
}

private void flowDiagram1_DragOver(object sender, DragEventArgs e)
{
  if (!m_bDragging)
    flowDiagram1_DragDrop(sender, e);
}

private void flowDiagram1_DragDrop(object sender, DragEventArgs e)
{
  MessageBox.Show("Drop");
}

1 个答案:

答案 0 :(得分:1)

我认为你需要添加它来拖延:

if(e.Data.GetDataPresent(DataFormats.Text))
    e.Effect = DragDropEffects.Move;
  else
    e.Effect = DragDropEffects.None;