Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Moving & resizing controls at runtime

Moving & resizing controls at runtime

Scheduled Pinned Locked Moved C#
tutorialquestion
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dewald
    wrote on last edited by
    #1

    I'm looking for a way to make it possible for the user to move a control on the form (or let's say inside a panel) during runtime by clicking and dragging with the mouse. Also, I'd like for the user to be able to resize the control by clicking on the edges and dragging. Could someone point me to an article on how to do this perhaps or even explain the key principles in this thread please? I suppose it's almost like creating a runtime form editor but I have no need to add controls at runtime. I just want to be able to resize and move one control that will already be on the form.

    D H P 3 Replies Last reply
    0
    • D Dewald

      I'm looking for a way to make it possible for the user to move a control on the form (or let's say inside a panel) during runtime by clicking and dragging with the mouse. Also, I'd like for the user to be able to resize the control by clicking on the edges and dragging. Could someone point me to an article on how to do this perhaps or even explain the key principles in this thread please? I suppose it's almost like creating a runtime form editor but I have no need to add controls at runtime. I just want to be able to resize and move one control that will already be on the form.

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      I think you'll need to capture mouse down, mouse move and mouse up events on the controls and set their Location or Size properties accordingly. To display handles on them you'll need to override their OnPaint methods.

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      1 Reply Last reply
      0
      • D Dewald

        I'm looking for a way to make it possible for the user to move a control on the form (or let's say inside a panel) during runtime by clicking and dragging with the mouse. Also, I'd like for the user to be able to resize the control by clicking on the edges and dragging. Could someone point me to an article on how to do this perhaps or even explain the key principles in this thread please? I suppose it's almost like creating a runtime form editor but I have no need to add controls at runtime. I just want to be able to resize and move one control that will already be on the form.

        H Offline
        H Offline
        Hossein Afyuoni
        wrote on last edited by
        #3

        For resize controls, u can change the size of control:

        control.height = x
        control.weight = y

        & for move its, u can change the location of its:

        control.left = X
        control.top = Y

        u must write these code to event that u want (for example mouse click btn)...

        N 1 Reply Last reply
        0
        • H Hossein Afyuoni

          For resize controls, u can change the size of control:

          control.height = x
          control.weight = y

          & for move its, u can change the location of its:

          control.left = X
          control.top = Y

          u must write these code to event that u want (for example mouse click btn)...

          N Offline
          N Offline
          netJP12L
          wrote on last edited by
          #4

          I guess the this user wants to know how can he display handles around the control

          1 Reply Last reply
          0
          • D Dewald

            I'm looking for a way to make it possible for the user to move a control on the form (or let's say inside a panel) during runtime by clicking and dragging with the mouse. Also, I'd like for the user to be able to resize the control by clicking on the edges and dragging. Could someone point me to an article on how to do this perhaps or even explain the key principles in this thread please? I suppose it's almost like creating a runtime form editor but I have no need to add controls at runtime. I just want to be able to resize and move one control that will already be on the form.

            P Offline
            P Offline
            Pedram Behroozi
            wrote on last edited by
            #5

            I created a simple search in Google and I found this[^] for resizing and this[^] for dragging in less than a minute. Always try Google, MSDN and CP articles first, they're more and more and even more faster. Maybe you should visit here[^] before you post your post here[^] :)

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups