Treeview Problem - I just can't see it.. 
Author Message
 Treeview Problem - I just can't see it..

Hi,

I was wondering if anyone can tell me where I'm going wrong?

I have a treeview and listview control and I am trying to allow the user
to drag and drop an item from the listview to the treeview control.  I
have managed to get this much to the work but the problem is that the
selected items never drop in the correct location.  They will either
drop in as a child node in the last created node (I am populating the
treeview from a sqlserver table) or else they drop as child of the Root
node.

Below is the code I've been playing with (pardon the mess) but I am
obviously missing something here as I just can't get it to work at the
moment.  I've tried several combinations I came across on this newsgroup
but no joy so far.

Any help or suggestions would be good.

Thanks.

-------------------------------------------------------------------
Private Sub TreeView1_DragDrop(Source As Control, x As Single, y As Single)
    Dim DragItem As ListItem 'Listview item that was dragged
    Dim NewNode As Node 'New treeview node
    'Dim DropNode As Node 'Node that the dragged item was dropped on

             If TypeOf Source Is ListView Then

                 'Set DropNode = TreeView1.DropHighlight
                 'Set DropNode = TreeView1.SelectedItem

'                Set gnode = TreeView1.DropHighlight
'                Set gnode = TreeView1.SelectedItem
                 TreeView1.SelectedItem = TreeView1.DropHighlight

                 'Assign the selected item from the listview to 'DragItem'
                 Set DragItem = ListView1.SelectedItem
                 'Add a new child node to the node that was selected for
the drop
                 'Set gnode = TreeView1.Nodes.Add(gnode, tvwChild,
ListView1.SelectedItem.Text, ListView1.SelectedItem.Text)
                 Set NewNode = TreeView1.Nodes.Add(gnode, tvwChild,
ListView1.SelectedItem.Text, ListView1.SelectedItem.Text)

                 'Remove the selected list item from the listview
                 Source.ListItems.Remove (DragItem.Index)
                 'Remove the drophighlight from the treeview
                 Set TreeView1.DropHighlight = Nothing
             End If



Sun, 18 Dec 2005 17:33:11 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. 'Canned' data in VB program

2. Bizarre problem - VB6 won't see one .EXE file but sees all others

3. Seeing icons into TreeView

4. help: text justed in reports access

5. HELP : Treeview and drag'n drop problem.

6. TreeView: Aligning data problem (vbTab doesn't work)

7. Some weird run time error I've never seen before

8. Some wierd error I've never seen before

9. I'm seeing red

10. An Api I haven't seen

11. Weirdest bug I've ever seen

12. ? Internet connection sharing, I've seen this posted several times by people

 

 
Powered by phpBB® Forum Software