473,698 Members | 2,153 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 1413
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
1883
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 obviously)? Do I need to use a splitter? Any info would be appreciated very much.
3
2164
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
1432
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. Then, I'm trying to iterate through my dataset and build all the folders and files under the root node.
3
1802
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
6823
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
11221
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> <asp:TreeNodeStyle CssClass="homenav" Font-Underline="False" />
1
2134
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 question: Why does it affect BOTH Treeview, since they are
2
2100
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: xmlDoc.getElementsByTagName("to"); The standalone file is named treeView.htm (attached). You should be
9
6126
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
8603
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8893
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4366
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2328
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.