473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

i need to implement drag and drop in treeview in VB

i need to implement drag and drop in treeview in VB.
Kindly help.
My treeview contains activities maintained using XML Files.
Hopefully, Thanks.

Aug 7 '06 #1
1 1841
Hi Pooja-

You can implement drag and drop with the DataObject (the "clipboard").

In the form that hosts the TreeView control (perhaps in the TreeViews
MouseMove Event):

Private Sub treeFileInfoTree_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles treeFileInfoTree.MouseMove

Dim tBase as TreeView
Dim data as New DataObject
'If no mouse button pressed, then assume no dragdrop
If e.Button = MouseButtons.None Then Exit Sub
tBase = DirectCast(sender, TreeView)
'Exit sub if button pressed but mouse is not over treeview node
If tBase.SelectedNode.Bounds.Contains(e.X, e.Y) Then Exit Sub
'Assign data to clipboard
data.SetData(DataFormats.Text, tBase.SelectedNode.Text)
'Begin Drag Operation
Dim effect As DragDropEffects = DragDropEffects.Copy
effect = tBase.DoDragDrop(data, effect) 'wait here until drop complete

End Sub

Then you need to add code to the DragDrop event of the control where the
drop is occuring:

Private Sub ListBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles lstOriginal.DragDrop

Dim lBase As ListBox = DirectCast(sender, ListBox)
lBase.Items.Add(e.Data.GetData(DataFormats.Text).T oString)

End Sub

"pooja" wrote:
i need to implement drag and drop in treeview in VB.
Kindly help.
My treeview contains activities maintained using XML Files.
Hopefully, Thanks.

Aug 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Flickinger | last post by:
I have been using a label with the TreeView control - to simulate the ghost image of a node during drag/drop (so that a ghost of the node appears to be floating next to the cursor on a drag/drop)....
1
by: Kevin Henkener | last post by:
I would like to be able to drag-n-drop System.Windows.Forms.TreeNode objects between two different applications (actually the same application, just two instances of it) in C#. I've seen posts in...
0
by: Norbert Heidbüchel | last post by:
Hi all, I have read a lot of postings and web pages about drag and drop and treeviews, but could not find an answer to my problem. Sorry, if I missed something. I am trying to drag and drop...
4
by: Qingdong Z. | last post by:
I have a VS.NET windows application which use drag-drop feather. It works fine when application start, but stops working after application run one or two days. The application is related to Video...
1
by: emferrari | last post by:
Hi everybody I have two treeviews, one of them is only to receive items dragged from the treeview1. I want to know how to drag a full node information to the treeview2. I know how to do that...
2
by: Yoshitha | last post by:
Hi In my application am using list box and treeview controls list box contains the files and the treeview contains files,folderrs and subfolders. I'll select a file from listbox and drag it and...
1
by: vinaykumar Maladkar | last post by:
Hi Friends, I m uisng visual studio 2005 and C#. I m showing some values say 1 to 10 in a treeview control. and i want to implement drag and drop facility. i.e. any number can be moved to any...
0
by: munishbatra2002 | last post by:
hi all, we are using a gridview and a treeview control ... we want to drag a row from gridview control and drop it onto treeview control on a web page... we are using C# ASP.NET ... can anyone...
2
by: bob | last post by:
Hi all, I have a treeview that has drag drop. Works well enough but... If you drag out of bounds of the treeview the nodrop icon comes on. Fair enough. But when I move back inside the treeview...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.