RadPanels Drag and Drop

2 posts, 0 answers
  1. R
    R avatar
    8 posts
    Member since:
    Apr 2008

    Posted 30 Jun 2008 Link to this post

    Hi.

    I have a  RadPanel with several RadPanels inside. I want to be able to drag and drop the RadPanels to change their location inside the main RadPanel. Can you help me with that?

    Thanks

  2. Jack
    Admin
    Jack avatar
    2335 posts

    Posted 01 Jul 2008 Link to this post

    Hello,

    Thank you for contacting us.

    A possible solution would be to use a descendant class of the RadPanel and override the OnMouseMove method. This behavior is demonstrated in the following code snippet:

        public class MyPanel : RadPanel 
        { 
            Point downPoint; 
     
            protected override void OnMouseDown(MouseEventArgs e) 
            { 
                base.OnMouseDown(e); 
                downPoint = e.Location; 
            } 
     
            protected override void OnMouseMove(MouseEventArgs e) 
            { 
                base.OnMouseMove(e); 
                if (e.Button == MouseButtons.Left) 
                { 
                    Point delta = new Point(e.X - downPoint.X, e.Y - downPoint.Y); 
                    Console.WriteLine("Delta: x = {0}, y = {1}", delta.X, delta.Y); 
                    this.Location = new Point(this.Location.X + delta.X, this.Location.Y + delta.Y); 
                } 
            } 
     
            public override string ThemeClassName 
            { 
                get 
                { 
                    return typeof(RadPanel).FullName; 
                } 
                set 
                { 
                } 
            } 
        } 
     


    I hope this helps. Do not hesitate to write me if you have any other questions.

    Best wishes,
    Jack
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top