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. Temporary Modification in a Control During Drag and Drop

Temporary Modification in a Control During Drag and Drop

Scheduled Pinned Locked Moved C#
question
3 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.
  • S Offline
    S Offline
    Som Shekhar
    wrote on last edited by
    #1

    There are a some rectangular controls on a winform on which a dragdrop can happen. When an item (which has a numeric value) is dragged over any of these controls, the control should show possible result by changing its shape (Increase area by numeric value). This should be temporary. In case i move the item it out of the control without dropping, this change should revert back. Only in case the drop is done, the change should be permanent. Now, this effect can be achieved using DragEnter and DragLeave. Currently, I am making the modification to the Control two times by adding the changes and removing the changes. What I want to know now is whether it is possible to save the state of control so that it can be reverted back to the old state. In reality, the changes are complicated than just adding area into the shape. But the concept remains same. Control needs to change temporarily and a simple method to restore its state needs to be achieved. Is it possible?

    L 1 Reply Last reply
    0
    • S Som Shekhar

      There are a some rectangular controls on a winform on which a dragdrop can happen. When an item (which has a numeric value) is dragged over any of these controls, the control should show possible result by changing its shape (Increase area by numeric value). This should be temporary. In case i move the item it out of the control without dropping, this change should revert back. Only in case the drop is done, the change should be permanent. Now, this effect can be achieved using DragEnter and DragLeave. Currently, I am making the modification to the Control two times by adding the changes and removing the changes. What I want to know now is whether it is possible to save the state of control so that it can be reverted back to the old state. In reality, the changes are complicated than just adding area into the shape. But the concept remains same. Control needs to change temporarily and a simple method to restore its state needs to be achieved. Is it possible?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I would derive new Control types that do this, so make a ReshapableButton inheriting from Button, etc. And give them a boolean Reshaped property. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
      All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.


      S 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, I would derive new Control types that do this, so make a ReshapableButton inheriting from Button, etc. And give them a boolean Reshaped property. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
        All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.


        S Offline
        S Offline
        Som Shekhar
        wrote on last edited by
        #3

        OK. This is already there. Whenever there is a DragLeave event, the control checks if it was reshaped and then it draws itself once again after making changes back. My question is how to save the details of control during DragEnter which can be easily resumed at DragLeave. Serialization could be one solution. However implementing that within a class to handle itself, seems a bit tricky. Forms cannot be serialized easily. So, basically I need a control that can save its state by serializing itself. When needed, it resumes from the serialized data. The fact that the control is on UI thread and it has to be a self managed code makes it tricky. I just need a clue how to implement this.

        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