I try other approach, use the timer to slow down the things. When is
disabled I do the EnsureVisible for the sibblings nodes. The tick handler
disable the timer and when I call EnsureVisible I enabled the timer. The
interval is 250 miliseconds, so the scroll only occurs at this speed,
....thanks for tellme about the timer!!
The Final Working Code is:
public class DragDropTreeview : TreeView
{
#region Fields & Properties
private TreeNode srcNodeForDrag;
Timer temporizador = new Timer();
#endregion
#region Constructors
public DragDropTreeview()
{
this.AllowDrop = true;
temporizador.Interval = 250;
temporizador.Tick += (x, y) => { temporizador.Enabled =
false; };
}
#endregion
protected override void OnDragOver(DragEventArgs e)
{
if (!temporizador.Enabled)
{
Point pt = PointToClient(new Point(e.X, e.Y));
TreeNode DestinationNode = this.GetNodeAt(pt);
DestinationNode.PrevVisibleNode.EnsureVisible();
DestinationNode.NextVisibleNode.EnsureVisible();
temporizador.Enabled = true;
}
if ((e.KeyState & 8) == 8 &&
(e.AllowedEffect & DragDropEffects.Copy) ==
DragDropEffects.Copy)
{
// CTL KeyState for copy.
e.Effect = DragDropEffects.Copy;
}
else if ((e.AllowedEffect & DragDropEffects.Move) ==
DragDropEffects.Move)
{
e.Effect = DragDropEffects.Move;
}
}
..... the rest remains unchanged.