Link to home
Start Free TrialLog in
Avatar of beidebenen
beidebenenFlag for Netherlands

asked on

Drag and drop to a specified place i a field using MSComctlLib.TreeCtrl.2

I using a treeview to show some default text an like to use drag an drop to put the default text in a controlbox.

So far so good BUT

I like to drop the default text (for example) inside the text I have already placed in a textcontrol. Who can help me with this problem.
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Access doesn't do drag and drop. Your Treeview may support it, but that would only be between another control that also supported drag and drop.

There are some alternatives, but I'm not sure they would work with your Treeview:

www.peterssoftware.com (Drag and Dropper)

How to simulate Drag and Drop:
http://support.microsoft.com/kb/287642

http://accessblog.net/2007/04/drag-and-drop-in-access.html
Avatar of beidebenen

ASKER

I change my design and using now a forms.TextBox.1 and the treeview control. It works but now the value I drag is moving from my treeview list.

Ok it is drag and drop but :)

I like to drop the value and leave the treeview list in order.  So I hope someone can tell me what I do wrong.


Private Sub TvScript_OLEDragOver(Data As Object, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single, State As Integer)
    Dim nodSelected As Node
    Dim nodOver As Node
    Dim tv As TreeView
    
    Set tv = Me.TvScript.Object
    
    If tv.SelectedItem Is Nothing Then
        'Select a node if one is not selected
        Set nodSelected = tv.HitTest(x, y)
        If Not nodSelected Is Nothing Then
            nodSelected.Selected = True
        End If
    Else
        tv.SelectedItem.Selected = True
    End If
 
End Sub

Open in new window

I'm not sure what you mean by "leave the treeview list in order" ... all your code does is select a Node in your treeview, so I'm not clear what you're asking.
First I like to thank you for your comment.

By example:

I click at one of the nodes in the treeview. (the value of the node is "Test")

I like to drag the value to a forms.textbox.1 (because I will drop the value at a specified place in the text)

When I use the default drag and drop actions the first two steps are going right but...

After this action the value, i have draged from the treeview,  is no longer available and visible in my treeview.
So your Drag event FROM the Treeview removes it from the Treeview?

If I'm not mistaken, there are several properties you can set for your Treeview that will allow you to "copy" instead of "cut" ... check the properties and see what you find.
ASKER CERTIFIED SOLUTION
Avatar of beidebenen
beidebenen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Right ... I knew there were some "option" settings available, but couldn't remember how to invoke them. I don't use the MS treeview anymore, so it's been a while since I've worked with it.
Generally when a suggestion by an Expert helps you to solve your problem you would assign points to that Expert ...