Do drag n drop in VB.Net in fifteen lines of code - (too easy)

  • Thread starter James Allen Bressem
  • Start date
J

James Allen Bressem

- hehe - When you're explaining every angle of a socio economic scenario in
the context of a review of current technical issues it can take a little
time to get it right - slibS, slibW, slibD (so let it be Written, so let it
be Said, so let it be Done)

I was searching through the MSDN documentation trying to figure out how to
do drag n drop and I found a sample program. The sample program did all
sorts of fancy junk like dynamically create it's user controls etc. (pomp -
is it really necessary to be so gaudy when trying to explain a simple
point?) So, realizing the state of the economy and the period of history in
which I was so unfortunately born, I spent the next 3 or so hours weeding
through the affectatious displays of bravado and uselessly flagrant
manefestations of excess (blank lines every where in the sample code - What
does "CONCISE" mean?)

When a people are showing a near complete, generally applicable, state of
chaotic ineptitude something is wrong with the system, though it may look
fine on the outside. Which is why we have UCOM www.UCOM-ISM.com shedding
light on the source of and solution for these obvious yet completely
overlooked social problems.

Anyway; I eventually was able to find the actual code that was necessary to
do drag n drop in VB.NET:

There was 500 lines of code in the sample using a ListBox control!
I was able to do drag n drop in a TreeView control with 15 lines of code?
'---------------------------------------------------------------------------
----------------------------------
Protected Sub TreeView1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseMove
Dim sNodePathStr As String
sNodePathStr = LinkTree.SelectedNode.FullPath()
Dim dropEffect As DragDropEffects = TreeView1.DoDragDrop(sNodePathStr,
DragDropEffects.Copy)
End Sub
Private Sub TreeView1_DragOver(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TreeView1.DragOver
e.Effect = DragDropEffects.Copy
End Sub
Private Sub TreeView1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TreeView1.DragDrop
Dim oNode As TreeNode
Dim oDroppedNodePath As Object =
CType(e.Data.GetData(GetType(System.String)), System.Object)
Debug.WriteLine("Selected Item: " & CType(oDroppedNodePath, String))
oNode = TreeView1.GetNodeAt(e.X, e.Y)
Debug.WriteLine("Drop Site: " & oNode.FullPath)
End Class
'---------------------------------------------------------------------------
----------------------------------

--
-----------------------------
Name: James Allen Bressem
Phone: (323) 691-4279
Email: (e-mail address removed)
UCOM: http://www.ucom-ism.com
Mirror site: http://www.geocities.com/wizardofwizards
-----------------------------
 
F

Fergus Cooney

Yo JABBA

Today it is Sunday - And God said let there be Trolls.

|| slibS, slibW, slibD

small library String, Word and DoubleWord.

--
(Please ignore this - there's a feud going on)
==================================================
Quote of the day
Herfried:
I don't need/want human interaction.
==================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top