|
-
Mar 28th, 2003, 02:46 AM
#1
Thread Starter
Fanatic Member
Find Node in TreeView
hi
as we can get the node in vb6 i need the VB.net
Code:
'VB6 code
dim Nd as Nde
set Nd=Treeview.nodes("Khalik") ' khalik is the key
simple i need to find out if the node already created..
if not i need to add node or skip it....
is there away to find node
-
Mar 28th, 2003, 10:40 AM
#2
Addicted Member
simply trap the error that you will receive if you try to add a node with a key that already exists and deal with it in the catch block - i.e. flag a message or generate a new unique id and retry etc.
Cheers..
-
Mar 28th, 2003, 11:56 PM
#3
Thread Starter
Fanatic Member
Originally posted by powdir
simply trap the error that you will receive if you try to add a node with a key that already exists and deal with it in the catch block - i.e. flag a message or generate a new unique id and retry etc.
Cheers..
thanks powdir .. i belive u got it wrong...
before i add a node to treeview i need to find out if exists i need to do diff operation and if not then add the node...
i know if i loop around the nodes collection i can find that but do we have a method which does the job....?
-
Mar 29th, 2003, 01:52 AM
#4
No there is no intrinsic method to find a node. You'll need to write one.
Here is a previous post on the subject:
http://www.vbforums.com/showthread.p...hreadid=236652
-
Apr 1st, 2003, 05:39 AM
#5
Thread Starter
Fanatic Member
might be of use to some one like me........
well i have written 2 sample function for finding the node
first will return Boolean wheather Node Found or Not.
Second function Return the Node.
Code:
Function TV_FindNode(ByVal nNode As TreeNodeCollection, ByVal Str As String) As Boolean
Dim n As TreeNode
For Each n In nNode
If n.Text = Str Then
n.Text = Str
Return True
' Exit For
End If
Next
Return False
End Function
Function TV_FindRetNode(ByVal nNode As TreeNodeCollection, ByVal Str As String) As TreeNode
Dim n As TreeNode
For Each n In nNode
If n.Text = Str Then
n.Text = Str
Return n
End If
Next
End Function
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|