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("Left Node 1", 1, "Left Node Information"))
.Add(New myTreeNode("Left Node 2", 2, "Left Node Information"))
End With
With tvwRight.Nodes
.Clear()
.Add(New myTreeNode("Right Node 1", 1, "Right Node
Information"))
.Add(New myTreeNode("Right Node 2", 2, "Right Node
Information"))
End With
/*===============
Drag and Drop Handling :
/*===============
Private Sub TreeView_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) _
Handles tvwLeft.DragDrop, tvwright.DragDrop
Dim OriginationNode As TreeNode =
CType(e.Data.GetData("System.Windows.Forms.TreeNod e"), TreeNode)
If e.Data.GetDataPresent("System.Windows.Forms.TreeNo de", False)
Then
Dim pt As Point
Dim DestinationNode As TreeNode
pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))
DestinationNode = CType(sender, TreeView).GetNodeAt(pt)
DestinationNode.Nodes.Add(CType(OriginationNode.Cl one,
TreeNode))
DestinationNode.Expand()
End Sub
Private Sub TreeView_DragEnter(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) _
Handles tvwLeft.DragEnter, tvwright.DragEnter
If (e.Data.GetDataPresent("System.Windows.Forms.TreeN ode")) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Private Sub TreeView_ItemDrag(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.ItemDragEventArgs) _
Handles tvwLeft.ItemDrag, tvwright.ItemDrag
If e.Button = MouseButtons.Left Then
DoDragDrop(e.Item, DragDropEffects.Copy)
End If
End Sub
/*===============
Thanks
Kelvin Leung
"Chris Calzaretta" <cc*********@hotmail.com> ¦b¶l¥ó
news:%2****************@TK2MSFTNGP14.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*******@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP10.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