Jump to content
Tuts 4 You

Edit History

whoknows

whoknows

the solution I have implement for this, on a C# is the  DragOver event 

        private void TR_DragOver(object sender, DragEventArgs e)
        {
 >>>>>>>>>           NativeMethods.Scroll(TR);

            TreeView tree = (TreeView)sender;

            e.Effect = DragDropEffects.None;

            if ((e.Data.GetData(typeof(TreeNode)) != null))
            {
                Point pt = new Point(e.X, e.Y);
                pt = tree.PointToClient(pt);
                TreeNode node = tree.GetNodeAt(pt);

                if ((node != null))
                {
                    e.Effect = DragDropEffects.Move;
                    tree.SelectedNode = node;
                }

            }
        }

//NativeMethods Class
    public static class NativeMethods
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        public static void Scroll(this Control control)
        {
            var pt = control.PointToClient(Cursor.Position);

            if ((pt.Y + 20) > control.Height)
            {
                // scroll down
                SendMessage(control.Handle, 277, (IntPtr)1, (IntPtr)0);
            }
            else if (pt.Y < 20)
            {
                // scroll up
                SendMessage(control.Handle, 277, (IntPtr)0, (IntPtr)0);
            }
        }
    }

 

ref
stackoverflow.com/questions/6034942/treeview-autoscroll-while-dragging
www.syncfusion.com/faq/windowsforms/treeview/how-do-i-make-the-treeview-scroll-when-i-drag-an-item-to-the-top-or-bottom
social.msdn.microsoft.com/Forums/en-US/a336643c-11a9-451a-9d68-da0fd072383c/treeview-drag-drop-scrolling

whoknows

whoknows

the solution I have implement for this, on a C# is the  DragOver event 

        private void TR_DragOver(object sender, DragEventArgs e)
        {
 >>>>>>>>>           NativeMethods.Scroll(TR);

            TreeView tree = (TreeView)sender;

            e.Effect = DragDropEffects.None;

            if ((e.Data.GetData(typeof(TreeNode)) != null))
            {
                Point pt = new Point(e.X, e.Y);
                pt = tree.PointToClient(pt);
                TreeNode node = tree.GetNodeAt(pt);

                if ((node != null))
                {
                    e.Effect = DragDropEffects.Move;
                    tree.SelectedNode = node;
                }

            }
        }

//NativeMethods Class
    public static class NativeMethods
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

        public static void Scroll(this Control control)
        {
            var pt = control.PointToClient(Cursor.Position);

            if ((pt.Y + 20) > control.Height)
            {
                // scroll down
                SendMessage(control.Handle, 277, (IntPtr)1, (IntPtr)0);
            }
            else if (pt.Y < 20)
            {
                // scroll up
                SendMessage(control.Handle, 277, (IntPtr)0, (IntPtr)0);
            }
        }
    }

 

ref
stackoverflow.com/questions/6034942/treeview-autoscroll-while-dragging
www.syncfusion.com/faq/windowsforms/treeview/how-do-i-make-the-treeview-scroll-when-i-drag-an-item-to-the-top-or-bottom
social.msdn.microsoft.com/Forums/en-US/a336643c-11a9-451a-9d68-da0fd072383c/treeview-drag-drop-scrolling

whoknows

whoknows

the solution I have implement for this, on a C# is the  DragOver event 

        private void TR_DragOver(object sender, DragEventArgs e)
        {
            NativeMethods.Scroll(TR);

            TreeView tree = (TreeView)sender;

            e.Effect = DragDropEffects.None;

            if ((e.Data.GetData(typeof(TreeNode)) != null))
            {
                Point pt = new Point(e.X, e.Y);
                pt = tree.PointToClient(pt);
                TreeNode node = tree.GetNodeAt(pt);

                if ((node != null))
                {
                    e.Effect = DragDropEffects.Move;
                    tree.SelectedNode = node;
                }

            }
        }

 

ref
stackoverflow.com/questions/6034942/treeview-autoscroll-while-dragging
www.syncfusion.com/faq/windowsforms/treeview/how-do-i-make-the-treeview-scroll-when-i-drag-an-item-to-the-top-or-bottom
social.msdn.microsoft.com/Forums/en-US/a336643c-11a9-451a-9d68-da0fd072383c/treeview-drag-drop-scrolling

×
×
  • Create New...