472,351 Members | 1,459 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

Help - TreeView Question

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
Nov 21 '05 #1
3 1337
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

Nov 21 '05 #2
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


Nov 21 '05 #3


As it looks it I think it seems to lay around


Dim DestinationNode As TreeNode

pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y))

DestinationNode = CType(sender, TreeView).GetNodeAt(pt)


and your not grabing the correct node

If you want I can help more. If you want you can shot a copy of the code to
Ch*************@mn.rr.com

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: fgh | last post by:
Hello, two questions please: 1) In a treeview, I want to display folders like it is done in Windows Explorer. Do I have to do this manually or...
3
by: Peter | last post by:
Hello Thanks for reviewing my question. I would like to know how can I programmatically select a node Thanks in Advanc Peter
3
by: Michael C | last post by:
Hi all, Quick question about the TreeView control. I'm using code like this to determine the currently clicked TreeNode in the TreeView. ...
0
by: Teemu | last post by:
Hello. Please bear with me if this seems like a basic question (I'm just getting started with all this ASP.NET and WebControls stuff). ...
3
by: Tom | last post by:
Sorry... new to this. I trying to figure out how to do a page redirect when someone clicks a treeview node. Does someone have a code snippet for...
14
by: Evan Kontos | last post by:
I am trying to implement a Treeview w/an XML file and I even copied and pasted examples from MSDN but can't get them to work. Any suggestions...
3
by: Gerhard | last post by:
I have the following code in an .net 2.0 project: <asp:Panel Runat="server" id="pnlNavigation" CssClass="pnlNavigation" Width="165px">...
1
by: Sam | last post by:
Hi, On my main form in my MDI application, I have two treeview, one on the right, which is actually a UserControl inherited from Treeview, and the...
2
by: hzgt9b | last post by:
I've written a simple javascript page that parses an XML file... (Actually I just modified the "Parsing an XML File" sample from...
9
by: auntiejack56 | last post by:
Hi, I've got a treeview, and I want to display the node text property that I have a) clicked on or b) highlighted using the up or down...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.