简体   繁体   中英

Control Drag Drop

I have a user control in c# on a windows form the drag drop events are only being fired around the edge of the control, does anyone have a clue what is causing this its driving me mad??

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");
}

I think you need to add this to drag over too:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM