private void treeViewChannel_MouseMove(object sender, MouseEventArgs e)
{
if ((e.Button & MouseButtons.Left) == MouseButtons.Left)
{
// If the mouse moves outside the rectangle, start the drag.
if (this.dragBoxFromMouseDown != Rectangle.Empty && !this.dragBoxFromMouseDown.Contains(e.X, e.Y))
{
// Child element must be remove if any
foreach (TreeNode tnParent in new ArrayList(this.treeViewChannel.SelectedNodes))
{
if (tnParent.GetNodeCount(false) > 0)
{
foreach (TreeNode tnProbableChild in new ArrayList(this.treeViewChannel.SelectedNodes))
{
if (tnProbableChild != tnParent && tnProbableChild.FullPath.IndexOf(tnParent.FullPath) == 0)
tnProbableChild.Checked = false;
}
}
}
// Proceed with the drag-and-drop, passing in the list item.
this.treeViewChannel.DoDragDrop(new ArrayList(this.treeViewChannel.SelectedNodes),
DragDropEffects.None | DragDropEffects.Copy | DragDropEffects.Move);
}
}
}