Allow Drop AND..
Ok, assuming you have all of your events being declared/created in the Form_Load... e.i.
:
tlAssemblies.DragDrop +=tlAssemblies_DragDrop;
tlAssemblies.MouseDown +=tlAssemblies_MouseDown;
tlAssemblies.MouseMove +=tlAssemblies_MouseMove;
tlAssemblies.DragEnter +=tlAssemblies_DragEnter;
tlAssemblies.DragOver += tlAssemblies_DragOver;
The drag Event is for when you fire the drag event inside your treeView which is why it is working. The dragEnter is when you enter the boundaries of a different* control.
i.e you want to drag from treeview 1 into treeview2.
If you are not trying to drag the item into a different control dragEnter is wrong.
Here is a drag drop event sample :
private void tlAssemblies_DragDrop(object sender, DragEventArgs e)
{
if (sender == null)
return;
Point p = tlAssemblies.PointToClient(new Point(e.X, e.Y));
TreeListNode dragNode = e.Data.GetData(typeof(TreeListNode)) as TreeListNode;
TreeListNode targetNode = tlAssemblies.CalcHitInfo(p).Node;
if (targetNode == null)
{
return;
}
}
Not sure if it is possible but you may want to change the dragEnter code you have and simply use it in the drag event i.e.
e.Effect = DragDropEffects.Move;
If you are not leaving the same control you are dragging both to and fro, might as well show the drag movement.
Another thing you could do is on the treeView_MouseMove Event.
private void tlAssemblies_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && downHitInfo != null)
{
Size dragSize = SystemInformation.DragSize;
Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2,
downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize);
if (!dragRect.Contains(new Point(e.X, e.Y)))
{
DataRow row = viewProduct.GetDataRow(downHitInfo.RowHandle);
if(row != null)
tlAssemblies.DoDragDrop(row, DragDropEffects.Move);
//viewProduct.GridControl.DoDragDrop(row, DragDropEffects.All);
downHitInfo = null;
DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;
}
}
}