Hello -
The following code should get you started (be sure to set the
TextBox.AllowDrop property to true)
Private Sub TreeView1_ItemDrag(ByVal sender As Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) Handles TreeView1.ItemDrag
TreeView1.DoDragDrop(TreeView1.SelectedNode.Text,
DragDropEffects.Copy Or DragDropEffects.Move)
End Sub
Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter
If (e.Data.GetDataPresent(DataFormats.Text)) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
TextBox1.Text = e.Data.GetData(DataFormats.Text).ToString
End Sub
Hope that helps
Steve Stein,
Visual Basic Team
--------------------------------------------------------------------
This reply is provided AS IS, without warranty (express or implied).
--------------------[color=blue]
>From:
hayesk@breathemail.net (K Hayes)
>Newsgroups: microsoft.public.dotnet.languages.vb
>Subject: Drag and Drop from TreeView Node to a TextBox
>Date: 5 Nov 2003 14:41:58 -0800
>Organization:
http://groups.google.com
>Lines: 32
>Message-ID: <a78be488.0311051441.204ad1c5@posting.google.com >
>NNTP-Posting-Host: 80.40.83.43
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1068072119 19631 127.0.0.1 (5 Nov 2003[/color]
22:41:59 GMT)[color=blue]
>X-Complaints-To:
groups-abuse@google.com
>NNTP-Posting-Date: Wed, 5 Nov 2003 22:41:59 +0000 (UTC)
>Path:[/color]
cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!postnew s1.google.com!no
t-for-mail[color=blue]
>Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:154032
>X-Tomcat-NG: microsoft.public.dotnet.languages.vb
>
>Hi All,
>
>Newish VB.NET programmer seeking help!
>
>I have a TreeView with a node that I wish to drag and drop to a
>Textbox.
>
>
>In the Treeview_ItemDrag i have
>
>DoDragDrop(e.item, DoDragDropEffects.ALL) - (I have tried copy aswell)
>
>
>In the Textbox DragEnter I have
>
>e.effect = DragDropEffects.All
>
>
>In the TextBox DragDrop I am declaring a string and attempting to copy
>the objects text to it as follows
>
>string = e.data.getdata(DataFormats.Text)
>
>the code runs, however, I have no data in my string and if I watch in
>the debugger it says "nothing"
>
>could anyone please advise as to what may be teh best and easiest
>thing to do please ??
>
>thank you in advance
>
>K!
>[/color]