以下代码拒绝在鼠标右键单击时进行拖放。当我右键单击鼠标时,我确实看到了正确的上下文菜单,但我无法拖放,尽管我确实有 DragDrop、DragEnter 和 DragOver 的事件处理程序。是因为我不能有上下文菜单并在同一次右键单击时拖放吗?我究竟做错了什么?非常感激您的帮忙。
private void treeList1_MouseDown(object sender, MouseEventArgs e)
{
TreeList tree = sender as TreeList;
Point pt = tree.PointToClient(MousePosition);
TreeListHitInfo info = tree.CalcHitInfo(pt);
if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && tree.State == TreeListState.Regular)
{
if (nodeType == typeof(X))
{
tree.ContextMenuStrip = XContextMenu;
tree.FocusedNode = info.Node;
treeList1.AllowDrop = true;
tree.AllowDrop = true;
}
currentFocusNode = tree.FocusedNode;
return;
}
}