Esempio n. 1
0
        private void TreeView_DragOver(object sender, DragEventArgs e)
        {
            TreeView            tree        = (TreeView)sender;
            Point               targetPoint = tree.PointToClient(new Point(e.X, e.Y));
            TreeNode            targetNode  = tree.GetNodeAt(targetPoint);
            DragDropInformation info        = (DragDropInformation)e.Data.GetData(typeof(DragDropInformation));

            if (info == null)
            {
                return;
            }
            TreeViewDragDropHelper.ImageList_DragMove(targetPoint.X, targetPoint.Y);
            //TreeViewDragDropHelper.ImageList_DragMove(e.X, e.Y);
            TreeNode sourceNode = info.SourceNode;

            if (info.Client.IsDropAllowed(sourceNode, targetNode))
            {
                TreeViewDragDropHelper.ImageList_DragShowNolock(false);
                tree.SelectedNode = targetNode;
                e.Effect          = e.AllowedEffect;
                TreeViewDragDropHelper.ImageList_DragShowNolock(true);
            }
            else
            {
                TreeViewDragDropHelper.ImageList_DragShowNolock(false);
                tree.SelectedNode = sourceNode;
                e.Effect          = DragDropEffects.None;
                TreeViewDragDropHelper.ImageList_DragShowNolock(true);
            }
        }
Esempio n. 2
0
            private void ScrollDown(Point pt)
            {
                TreeNode visibleNode = this.TreeView.GetNodeAt(pt);

                if (visibleNode == null)
                {
                    return;
                }

                TreeNode showNode = visibleNode.NextVisibleNode;

                if (showNode == null)
                {
                    showNode = visibleNode.NextNode;
                    if (showNode == null)
                    {
                        showNode = visibleNode.Parent;
                        if (showNode != null)
                        {
                            showNode = showNode.NextNode;
                        }
                    }
                }

                if (showNode != null)
                {
                    TreeViewDragDropHelper.ImageList_DragShowNolock(false);
                    showNode.EnsureVisible();
                    this.TreeView.Invalidate();
                    TreeViewDragDropHelper.ImageList_DragShowNolock(true);
                }
            }