Do drag n drop in VB.Net in ten lines of code - (too easy)
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_Mouse Move(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles TreeView1.Mouse Move
Dim sNodePathStr As String
sNodePathStr = LinkTree.Select edNode.FullPath ()
Dim dropEffect As DragDropEffects = TreeView1.DoDra gDrop(sNodePath Str,
DragDropEffects .Copy)
End Sub
Private Sub TreeView1_DragO ver(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles TreeView1.DragO ver
e.Effect = DragDropEffects .Copy
End Sub
Private Sub TreeView1_DragD rop(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles TreeView1.DragD rop
Dim oNode As TreeNode
Dim oDroppedNodePat h As Object =
CType(e.Data.Ge tData(GetType(S ystem.String)), System.Object)
Debug.WriteLine ("Selected Item: " & CType(oDroppedN odePath, String))
oNode = LinkTree.GetNod eAt(e.X, e.Y)
Debug.WriteLine ("Drop Site: " & oNode.FullPath)
End Class
'---------------------------------------------------------------------------
----------------------------------
-----------------------------
Name: James Allen Bressem
Phone: (323) 691-4279
Email: 18*****@SprintM ail.Com
UCOM: http://www.ucom-ism.com
Mirror site: http://www.geocities.com/wizardofwizards
-----------------------------