2 Replies - 461 Views - Last Post: 01 May 2013 - 06:45 AM Rate Topic: -----

#1 madamady  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 31-January 13

how to drag multiple selected controls

Posted 01 May 2013 - 04:49 AM

How can I drag multiple usercontrols ,which I select?There are created dynamically at runtime. I can drag one usercontrol,but many of them I can't manage to do it. I need just an idea how to do it. Thank you!
Is This A Good Question/Topic? 0
  • +

Replies To: how to drag multiple selected controls

#2 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5537
  • View blog
  • Posts: 11,868
  • Joined: 02-June 10

Re: how to drag multiple selected controls

Posted 01 May 2013 - 05:29 AM

Without the code you're using for 1 we can't help you with many. and "I can't figure it out" doesn't tell us your errors"

But basically use the same code that is successful for your single item. Just group your multiple controls into a single item: Such as a class or collection (List<UserControl>)
Was This Post Helpful? 0
  • +
  • -

#3 madamady  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 31-January 13

Re: how to drag multiple selected controls

Posted 01 May 2013 - 06:45 AM

My code used for dragging one usercontrol is:
  private void picturedrag_MouseDown(object sender, MouseEventArgs e)
        {
               Selected = true;
                _dragging = true;
                _dragStart = new Point(e.X, e.Y);
                picturedrag.Capture = true;
            }
 private void picturedrag_MouseUp(object sender, MouseEventArgs e)
        {
                _dragging = false;
                picturedrag.Capture = false;
            }

  private void picturedrag_MouseMove(object sender, MouseEventArgs e)
        {

                if (_dragging)
                {
                    this.Left = Math.Max(0, e.X + this.Left - _dragStart.X) / 10 * 10;

                    this.Top = Math.Max(0, e.Y + this.Top - _dragStart.Y) / 10 * 10;

                }

 public void StartDrag()
        {
                _dragging = true;
                Point p = PointToClient(Cursor.Position);
                _dragStart = new Point(Math.Max(0, p.X), Math.Max(0, p.Y));
                picturedrag.Capture = true;
            }


This post has been edited by Skydiver: 01 May 2013 - 06:53 AM
Reason for edit:: Put code in code tags.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1