473,748 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

TreeView Control: Highlight Multiple Nodes?

Mel
I have a treeview control that contains a list of filenames which I am
searching. If a file in the tree matches the search criteria the
entire node is expanded. Often times there are other files in that
expanded node that don't match the criteria. Is there a way to
highlight ALL the nodes that matched the search criteria?
Example Code (Using ASP.NET 2.0, Visual Basic):
Protected Sub btnSearch_Click (ByVal sender As Object, ByVal e As
System.EventArg s) Handles btnSearch.Click 'THIS IS MY SEARCH BUTTON
Dim find As Boolean = False
tvDocs.Collapse All()
Search(txtSearc h.Text, tvDocs.Nodes(0) , find) 'FIND THE
SEARCH CRITERIA IN THE TREE
If find = True Then tvDocs.Nodes(0) .Expand()

End Sub

Protected Sub Search(ByVal key As String, ByVal n As TreeNode,
ByRef find As Boolean)
Dim child As TreeNode
For Each child In n.ChildNodes
If (child.Text.ToL ower().StartsWi th(key.ToLower( ))) Then
ExpandParent(ch ild)
child.Selected = True 'WHEN THIS LOOP FINISHES ONLY
THE LAST NODE IS HIGHLIGHTED!
find = True
End If
Search(key, child, find)
Next
End Sub

Protected Sub ExpandParent(By Val n As TreeNode)
n.Expand()
If (Not n.Parent Is Nothing) Then
ExpandParent(n. Parent)
End If
End Sub

Nov 1 '07 #1
0 2185

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4370
by: Jarod_24 | last post by:
This is the exception i'm getting: System.InvalidOperationException: The action being performed on this control is being called from the wrong thread. You must marshal to the correct thread using Control.Invoke or Control.BeginInvoke to perform this action. I have multiple background-threads that returns info about their progress through a Event. This event's handler is then on a Form that has the responsability to display all the info...
0
1781
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 may not have some subdirectories with the same name. I am not having any problems populating the treeview with the corresponding directory structure when switching between radio buttons. In the treeview's AfterSelect event, I take the path from...
4
6929
by: praveen | last post by:
I have a form with treeview control loaded from xml document,text box, two buttons named "Find" and "FindNext" and my treeview which looks like below. Details |__ policy status |__ created by |__ cover type
3
4703
by: dutsnekcirf | last post by:
I have a treeview control on a custom task pane in Excel. I've enable the ability to use Drag & Drop (by following this how-to) on the treeview to change the order of the nodes. The problem though is if I close the application and then go back in, the nodes are back in the order they were before I had reordered them. Is there a way that I can modify my DragDrop event to permanently change the index of the nodes? Here's my code if you're...
0
8995
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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
9558
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...
0
9378
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9331
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
9253
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
8250
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
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2216
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.