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. Dynamicaly moving controls at runtime

Dynamicaly moving controls at runtime

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 3 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.
  • M Offline
    M Offline
    Mutty
    wrote on last edited by
    #1

    Hi - I'd like to dynamicaly move a button during runtime. I've tried changing the control's Control.Location.X and .Y but get the error: Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable. Is there a way to move a control at run time? Thanks, mutty

    M G 2 Replies Last reply
    0
    • M Mutty

      Hi - I'd like to dynamicaly move a button during runtime. I've tried changing the control's Control.Location.X and .Y but get the error: Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable. Is there a way to move a control at run time? Thanks, mutty

      M Offline
      M Offline
      Marc 0
      wrote on last edited by
      #2

      How about Control.Left or control.Top? Pompiedompiedom... ;)


      "..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick

      M 1 Reply Last reply
      0
      • M Marc 0

        How about Control.Left or control.Top? Pompiedompiedom... ;)


        "..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.." -- Mark McCormick

        M Offline
        M Offline
        Mutty
        wrote on last edited by
        #3

        So easy... Thanks!

        1 Reply Last reply
        0
        • M Mutty

          Hi - I'd like to dynamicaly move a button during runtime. I've tried changing the control's Control.Location.X and .Y but get the error: Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable. Is there a way to move a control at run time? Thanks, mutty

          G Offline
          G Offline
          gnjunge
          wrote on last edited by
          #4

          Well and if you want to know why you cannot change it: open reflector and see that the Location property returns the following:

          return new Point(this.x, this.y);

          So it is returning a new point object. If you anyway want to change the location of the control using the Location property you should feed it a new Point :

          Control.Location = new Point(X,Y);

          regards, Gidon

          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