The follwoing code refuses to work for drag and drop on the right mouse click. When I right click the mouse I do see the proper context menu but I am not able to drag and drop although I do have an event handler for DragDrop , DragEnter, and DragOver. Is it because I can’t have context menu and drag and drop on the same right click? what am I doing wrong? Your help is very much appreciated.
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;
}
}
You’re not calling the DoDragDrop method.
Here is an example of using DragDrop
In your example, add something like this before the
return;