Hi Chris
Thanks for your reply !
I would like to know why cannot work (Drag and Drop) after put sub-class
under treenode
And my source code as following :
Data Initial :
Can Work :
/*============== =
With tvwLeft.Nodes
.Clear()
.Add(¡§Left Node 1¡¨)
.Add(¡§Left Node 2¡¨)
End With
With tvwRight.Nodes
.Clear()
.Add(¡§Right Node 1¡¨)
.Add(¡§Right Node 2¡¨)
End With
/*============== =
Cannot Work After Added Sub-Class Information :
/*============== =
Class myTreeNode
Inherits TreeNode
Public MyShowText As String
Public MyIntg As Integer
Public MyStrng As String
Sub New(ByVal ShowText As String, ByVal Intg As Integer, ByVal
Strng As String)
MyBase.New()
MyShowText = ShowText
MyIntg = Intg
MyStrng = Strng
Me.Text = MyShowText
End Sub
End Class
With tvwLeft.Nodes
.Clear()
.Add(New myTreeNode("Lef t Node 1", 1, "Left Node Information"))
.Add(New myTreeNode("Lef t Node 2", 2, "Left Node Information"))
End With
With tvwRight.Nodes
.Clear()
.Add(New myTreeNode("Rig ht Node 1", 1, "Right Node
Information"))
.Add(New myTreeNode("Rig ht Node 2", 2, "Right Node
Information"))
End With
/*============== =
Drag and Drop Handling :
/*============== =
Private Sub TreeView_DragDr op(ByVal sender As System.Object, ByVal e As
System.Windows. Forms.DragEvent Args) _
Handles tvwLeft.DragDro p, tvwright.DragDr op
Dim OriginationNode As TreeNode =
CType(e.Data.Ge tData("System.W indows.Forms.Tr eeNode"), TreeNode)
If e.Data.GetDataP resent("System. Windows.Forms.T reeNode", False)
Then
Dim pt As Point
Dim DestinationNode As TreeNode
pt = CType(sender, TreeView).Point ToClient(New Point(e.X, e.Y))
DestinationNode = CType(sender, TreeView).GetNo deAt(pt)
DestinationNode .Nodes.Add(CTyp e(OriginationNo de.Clone,
TreeNode))
DestinationNode .Expand()
End Sub
Private Sub TreeView_DragEn ter(ByVal sender As System.Object, ByVal e As
System.Windows. Forms.DragEvent Args) _
Handles tvwLeft.DragEnt er, tvwright.DragEn ter
If (e.Data.GetData Present("System .Windows.Forms. TreeNode")) Then
e.Effect = DragDropEffects .Copy
Else
e.Effect = DragDropEffects .None
End If
End Sub
Private Sub TreeView_ItemDr ag(ByVal sender As System.Object, ByVal e As
System.Windows. Forms.ItemDragE ventArgs) _
Handles tvwLeft.ItemDra g, tvwright.ItemDr ag
If e.Button = MouseButtons.Le ft Then
DoDragDrop(e.It em, DragDropEffects .Copy)
End If
End Sub
/*============== =
Thanks
Kelvin Leung
"Chris Calzaretta" <cc*********@ho tmail.com> ¦b¶l¥ó
news:%2******** ********@TK2MSF TNGP14.phx.gbl ¤¤¼¶¼g...
post code that your having problems with.
You should be able to drag and drop from nodes with in nodes. As Explorer
which is the tree view.
"Kelvin Leung" <ke*******@hotm ail.com> wrote in message
news:es******** ******@TK2MSFTN GP10.phx.gbl... Hi
I use Drag and Drop between 2 TreeView Control under VB.Net
But I found that it cannot work when I add sub-class for each node
Is it drag and drop method cannot work when the node with sub-class ?
If no, any related information/reference ?
Thanks a lot
Kelvin