Drag and drop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sl1ver
    New Member
    • Mar 2009
    • 196

    Drag and drop

    anyone know where i can get help on making objects within the database(displa ys in tree view) able to be dragged and dropped in new locations? e.g. drag location A from house A to House C?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Are you assigning your object to the .Tag property of the treeView node?

    I would guess it to be something to the effect of using that Node.Tag object as the object of the D-n-D

    Comment

    • Sl1ver
      New Member
      • Mar 2009
      • 196

      #3
      here is some sample coding
      tvLocations.Sel ectedNode.Tag.T oString()
      any idea on how to make them able to change position withtin the tree view? obviously this change would be applied to database

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        Nodes only understand .Add and .Remove
        You would have to take the currently selected node...
        .Remove it from the node it belongs to, and
        .Add it to the node you want it on


        Here is how I determine a node based on mouse arguments so I can do a right-click which treeview's don't support in their events.

        Code:
                private void treeView1_MouseDown(object sender, MouseEventArgs e)
                {
                    if (e.Button == MouseButtons.Right)
                    {
                        TreeNode selectedNode = treeView1.GetNodeAt(e.X, e.Y);
                                //MessageBox.Show("You clicked on node: " + selectedNode.Text);
                        }
                       //else we ignore it for convenience
                    }
                }
        You should be able to tear this apart to work out the node selected at mouse down, and again at mouse up

        Comment

        • Sl1ver
          New Member
          • Mar 2009
          • 196

          #5
          Thanx for the help, much appreciated

          Comment

          Working...