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 controls in a form and store/restore the position

Moving controls in a form and store/restore the position

Scheduled Pinned Locked Moved C#
questionxml
2 Posts 2 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.
  • Y Offline
    Y Offline
    youssef
    wrote on last edited by
    #1

    Hi, I looking for create dynamically some control in a form with the possibility of moving each control anywhere in the form. I would like to store the position and store it to a xml files. After create some config, I would like to restore a specific config. My question is : How can I moving each control create dynamicaly with the mouse ? How can I retrieve the position of each control in the form ? Best Regards youssef

    M 1 Reply Last reply
    0
    • Y youssef

      Hi, I looking for create dynamically some control in a form with the possibility of moving each control anywhere in the form. I would like to store the position and store it to a xml files. After create some config, I would like to restore a specific config. My question is : How can I moving each control create dynamicaly with the mouse ? How can I retrieve the position of each control in the form ? Best Regards youssef

      M Offline
      M Offline
      MoustafaS
      wrote on last edited by
      #2

      In the class level : Point p = new Point(this.button1.Location.X,this.button1.Location.Y); In the mouse down event : void form1_mousedown() { //Write some code to add the point p to the config file ,Ican't remember how right now. this.p = new Point(-e.X,-e.Y); } In the mouse move event : void form1_mousemove() { if (e.Button == MouseButtons.Left) { Point mousepos = Control.MousePosition; mousepos.Offset(this.p.X,this.p.Y); this.button1.Location = mousepos; } }

      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