473,549 Members | 2,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1403
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

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("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


Nov 21 '05 #3


As it looks it I think it seems to lay around


Dim DestinationNode As TreeNode

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

DestinationNode = CType(sender, TreeView).GetNo deAt(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
1877
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 can I set something up in VS.NET 2003? 2) Most importantly, in Windows Explorer, you can drag the treeview's right edge to resize it to your will. How can I do this with my treeview (at runtime...
3
2151
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
441
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. private void MyTreeView_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { currentNode = MyTreeView.GetNodeAt(e.X, e.Y); }
0
1427
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). Anyway, I'm trying to programmatically build a treeview based off a dataset that I've queried from our database. First, I'm manually creating and adding the "root" node to the treeview control. ...
3
1800
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 this?
14
6795
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 welcome. XML File <TREENODES> <TREENODE TEXT="Document-1"> <TREENODE TEXT="Folder-1" EXPANDED="true"> <TREENODE TEXT="Document-2" />
3
11212
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"> <asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" CssClass="nav" BorderStyle="None" CollapseImageToolTip="" ExpandImageToolTip="" ShowExpandCollapse="False"> <LevelStyles>...
1
2127
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 other on the left. When I click on a node in the left Treeview, all the nodes in BOTH Treeview disappear for some milliseconds. First question: Why do I get this nasty effect? Second...
2
2088
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 http://www.w3schools.com/dom/dom_parser.asp) The page works great standalone... but when I try to make this work under frames I get "Error: Object required" when the following line executes:...
9
6120
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 arrows
0
7554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7511
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6088
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5119
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3509
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1087
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.