有谁知道我如何验证是否引发了事件是因为 DragAction 更改为取消,还是因为它实际上是从控件中拖出对象?
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.dragleave.aspx
[编辑]
在这一部分中,我开始在被拖动的对象中进行拖动。
void control_MouseDown(object sender, MouseEventArgs e)
{
var wasClicked = WasClicked;
if (wasClicked != null)
{
WasClicked(this, EventArgs.Empty);
}
// Select this UC on click.
if (IsSelected == false)
IsSelected = true;
else
IsSelected = false;
if (IsSelected == true)
{
_beingDragged = true;
DoDragDrop(this, DragDropEffects.Move);
}
return;
}
这部分事件在被拖动的对象离开 FlowLayoutPanel 时验证。
private void LocationControl_DragLeave(object sender, EventArgs e)
{
foreach (Control c in Controls)
{
if (((PersonDragDrop)c).beingDragged == true)
{
((PersonDragDrop)c).LeaveLocation();
DeletePerson((PersonDragDrop)c);
}
}
}