Hi,
while I'm searching into a treeview to find a specific node, I find the
code duplicating treeview nodes I just can't figure out what's causing this
behavior, maybe some of you already encountered this problem. Can someone
help please?
Here is the code of the functions causing this problem
Thanks
ThunderMusic
Private Function FindTVNode(ByVal Path As String) As TreeNode
Dim FoundNode As TreeNode
Dim Cpt As Integer
Dim Found As Boolean
Found = False
Cpt = 0
Do While (Not Found) And Cpt < TVAll.GetNodeCount(False)
If TVAll.Nodes.Item(Cpt).FullPath = Path Then
FoundNode = TVAll.Nodes.Item(Cpt)
Found = True
Else
FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then
Cpt += 1
Else
Found = True
End If
End If
Loop
FindTVNode = FoundNode
End Function
Private Function FindTVNodeRec(ByRef Node As TreeNode, ByVal Path As String)
As TreeNode
Dim FoundNode As TreeNode
Dim Cpt As Integer
Dim Found As Boolean
FoundNode = Nothing
Cpt = 0
Found = False
Do While Not (Found) And Cpt < Node.GetNodeCount(False)
If Node.Nodes.Item(Cpt).FullPath = Path Then
FoundNode = Node.Nodes.Item(Cpt)
Found = True
Else
FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then
Cpt += 1
Else
Found = True
End If
End If
Loop
FindTVNodeRec = FoundNode
End Function 2 1646
Hi,
Here is an example I made to search for a node and change its
text.
FindNodes(trvNorthWind.Nodes, "Robert King", "Ken Tucker")
Private Sub FindNodes(ByVal node As TreeNodeCollection, ByVal FindText As
String, _
ByVal NewText As String)
Dim tn As TreeNode
For Each tn In node
If tn.Text = FindText Then
tn.Text = NewText
End If
FindNodes(tn.Nodes, FindText, NewText)
Next
End Sub
Ken
------------
"ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message
news:%2********************@TK2MSFTNGP09.phx.gbl.. .
Hi,
while I'm searching into a treeview to find a specific node, I find the
code duplicating treeview nodes I just can't figure out what's causing this
behavior, maybe some of you already encountered this problem. Can someone
help please?
Here is the code of the functions causing this problem
Thanks
ThunderMusic
Private Function FindTVNode(ByVal Path As String) As TreeNode
Dim FoundNode As TreeNode
Dim Cpt As Integer
Dim Found As Boolean
Found = False
Cpt = 0
Do While (Not Found) And Cpt < TVAll.GetNodeCount(False)
If TVAll.Nodes.Item(Cpt).FullPath = Path Then
FoundNode = TVAll.Nodes.Item(Cpt)
Found = True
Else
FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then
Cpt += 1
Else
Found = True
End If
End If
Loop
FindTVNode = FoundNode
End Function
Private Function FindTVNodeRec(ByRef Node As TreeNode, ByVal Path As String)
As TreeNode
Dim FoundNode As TreeNode
Dim Cpt As Integer
Dim Found As Boolean
FoundNode = Nothing
Cpt = 0
Found = False
Do While Not (Found) And Cpt < Node.GetNodeCount(False)
If Node.Nodes.Item(Cpt).FullPath = Path Then
FoundNode = Node.Nodes.Item(Cpt)
Found = True
Else
FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then
Cpt += 1
Else
Found = True
End If
End If
Loop
FindTVNodeRec = FoundNode
End Function
thanks, it works fine. I don't what the other did that make the nodes
duplicate though.
Thanks a lot.
"Ken Tucker [MVP]" <vb***@bellsouth.net> a écrit dans le message de
news:uy**************@TK2MSFTNGP10.phx.gbl... Hi,
Here is an example I made to search for a node and change its text.
FindNodes(trvNorthWind.Nodes, "Robert King", "Ken Tucker") Private Sub FindNodes(ByVal node As TreeNodeCollection, ByVal FindText As String, _ ByVal NewText As String)
Dim tn As TreeNode
For Each tn In node If tn.Text = FindText Then tn.Text = NewText End If FindNodes(tn.Nodes, FindText, NewText) Next End Sub
Ken
------------ "ThunderMusic" <NO*******@sympatico.caSPAMATALL> wrote in message news:%2********************@TK2MSFTNGP09.phx.gbl.. . Hi, while I'm searching into a treeview to find a specific node, I find
the code duplicating treeview nodes I just can't figure out what's causing
this behavior, maybe some of you already encountered this problem. Can someone help please?
Here is the code of the functions causing this problem
Thanks
ThunderMusic
Private Function FindTVNode(ByVal Path As String) As TreeNode Dim FoundNode As TreeNode Dim Cpt As Integer Dim Found As Boolean
Found = False Cpt = 0
Do While (Not Found) And Cpt < TVAll.GetNodeCount(False) If TVAll.Nodes.Item(Cpt).FullPath = Path Then FoundNode = TVAll.Nodes.Item(Cpt) Found = True Else FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then Cpt += 1 Else Found = True End If End If Loop
FindTVNode = FoundNode End Function
Private Function FindTVNodeRec(ByRef Node As TreeNode, ByVal Path As
String) As TreeNode
Dim FoundNode As TreeNode Dim Cpt As Integer Dim Found As Boolean
FoundNode = Nothing Cpt = 0 Found = False
Do While Not (Found) And Cpt < Node.GetNodeCount(False) If Node.Nodes.Item(Cpt).FullPath = Path Then FoundNode = Node.Nodes.Item(Cpt) Found = True Else FoundNode = FindTVNodeRec(TVAll.Nodes.Item(Cpt), Path)
If FoundNode Is Nothing Then Cpt += 1 Else Found = True End If End If Loop
FindTVNodeRec = FoundNode End Function This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bill |
last post by:
0- (nodename) text1 4 text1 4
1 |-4 (node_parentname) text2 0 text2 5
2 OK fail
3
private void button1_Click(object sender,...
|
by: JoKur |
last post by:
I'm currently using a context menu to allow the user to add, rename and
delete nodes in a treeview control. When a node is added we give it a bogus
name ("NewNode") and invoke the add method. We...
|
by: ThunderMusic |
last post by:
Hi,
while I'm searching into a treeview to find a specific node, I find the
code duplicating treeview nodes I just can't figure out what's causing this
behavior, maybe some of you already...
|
by: EOS |
last post by:
Hi,
I am new to PDA development and my background is purely C/C++. Now I can get
the rought ideas on Compact C# .net for PDA development.
But I am having troubles on adding TreeView with nodes...
|
by: Treeview Trouble |
last post by:
I have an application where there are two radio buttons each of which
populates a treeview control with a directory structure. Each radio button
corresponds to a different directory which may or...
|
by: Kristopher Wragg |
last post by:
I'm having some serious problems with the TreeView control.
I've got a control that inherits TreeView and has some methods that
firstly create a TreeNode then does some recursive procedure to add...
|
by: serge calderara |
last post by:
Dear all,
I was wondering is there is a way to customise the treView control in order
to get any Control as a Node. What I try to do is having a Progress bar as a
treeview node object.
Is...
|
by: Marcelo Muzilli |
last post by:
Howdy all,
I´d like to know how can I get in a ArrayList (for example) all the
selected nodes from my TreeView object.
I´m trying to use the following code and is not working. Why?
Do you...
|
by: arggg |
last post by:
I am trying to add child nodes based on database query in which the users in the database are a part of the parent node. Here is my code.
private void GetUsersByGroup()
{
...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
| |