Results 1 to 7 of 7

Thread: Drag Drop????

  1. #1

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Question

    how can i drag a node, from a tree view control, into a textbox, and have it show the title of the node?

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    In the treeview's MouseDown event;

    Treeview1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button=1 Then Exit Sub

    'only drag with right mouse button
    Treeview1.SelectedItem = Treeview1.HitTest(X, Y)
    Treeview1.DragIcon = Treeview1.SelectedItem.CreateDragImage
    Treeview1.Drag 1

    End Sub

    Make sure the treeview's dragmode property is Manual.
    You can get away without the TreeView1.DragIcon=.... line if you set a DragIcon in the treeview properties - otherwise it uses whatever icon is displayed on the treeview for that item.

    In the text box's DragDrop event;

    Private Sub txtView_DragDrop(Source As Control, X As Single, Y As Single)
    If Source.Name = "Treeview1" Then
    txtView.Text = Source.SelectedItem.Text
    End If

    End Sub



    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    thankyou very much, but what does "Hittest" do ?

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    .HitTest is a method of the treeview that determines which item the mouse is over based on the X and Y co-ordinates. You need it to determine which item you're dragging..

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  5. #5

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Thumbs up

    thank you veryt much

  6. #6
    New Member
    Join Date
    Oct 2004
    Posts
    11
    Can anyone tell me how to do this with VB.Net.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Resolved

    probably, if you ask in the Net forum


    Add the checkmark, and the word [RESOLVED] to your first post in this thread if it is resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width