|
-
Dec 17th, 2011, 12:13 AM
#1
Thread Starter
Junior Member
search text in treeview
Private Sub Form_Load()
TV.ImageList = ImageList1
TV.Nodes.Add , , , "sanu", 1 'add text and image from imagelist1
TV.Nodes.Add , , , "test", 1
TV.Nodes.Add , , , "strip", 1
TV.Nodes.Add , , , "list", 1
TV.Nodes.Add , , , "view", 1
TV.Nodes.Add , , , "time", 1
TV.Nodes.Add , , , "now", 1
TV.Nodes.Add , , , "yes", 1
End Sub
TextToSearch = "yes"
dim X as integer
for X = 0 to TV - 1
if TextToSearch = TV.nodes(x).text ' allways end up with error
next X
Note : i wanna search the text and remove TextTosearch and the image
Help me please VB6 master...
-
Dec 17th, 2011, 02:16 AM
#2
Re: search text in treeview
Try this
vb Code:
TextToSearch = "strip" Dim X As Integer For X = TV.Nodes.Count To 1 Step -1 If TextToSearch = TV.Nodes(X).Text Then TV.Nodes.Remove X End If Next X
Notes:
1- Nodes lower bound is 1 not 0
2- When you need to remove node inside a loop, you must use reverse order loop.
-
Dec 17th, 2011, 05:06 AM
#3
Thread Starter
Junior Member
Re: search text in treeview
 Originally Posted by 4x2y
Try this
vb Code:
TextToSearch = "strip"
Dim X As Integer
For X = TV.Nodes.Count To 1 Step -1
If TextToSearch = TV.Nodes(X).Text Then
TV.Nodes.Remove X
End If
Next X
Notes:
1- Nodes lower bound is 1 not 0
2- When you need to remove node inside a loop, you must use reverse order loop.
this is work like a charm...Thanks a lot and mark as solved...
-
Dec 17th, 2011, 05:16 AM
#4
Re: search text in treeview
As you now have it sorted out, could you please do us a little favour, and mark the thread as Resolved?
(this saves time reading for those of us who like to answer questions, and also helps those who search to find answers)
You can do it by clicking on "Thread tools" just above the first post in this thread, then "Mark thread resolved". (like various other features of this site, you need JavaScript enabled in your browser for this to work).
Tags for this Thread
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
|