473,382 Members | 1,365 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Filtering data in TreeView

Hello,

I've created a treeview control that gives a folder browser view of a given
computer. The treeview is populated using the following methods:
Protected Sub treeDst_Init(ByVal sender As Object, ByVal e As
System.EventArgs) Handles treeDst.Init
Dim dirInfo As New DirectoryInfo("C:\")
dstDir.Text = dirInfo.FullName
For Each dir As DirectoryInfo In dirInfo.GetDirectories()
Dim node As TreeNode = New TreeNode(dir.Name, dir.FullName)
node.Expanded = False
node.PopulateOnDemand = True
CType(sender, TreeView).Nodes.Add(node)
Next
End Sub

Protected Sub PopulateNode(ByVal sender As Object, ByVal e As
TreeNodeEventArgs) Handles treeSrc.TreeNodePopulate, treeDst.TreeNodePopulate
On Error Resume Next

Dim dirInfo As New DirectoryInfo(e.Node.Value)
For Each dir As DirectoryInfo In dirInfo.GetDirectories()
Dim node As TreeNode = New TreeNode(dir.Name, dir.FullName)
node.Expanded = False
node.PopulateOnDemand = True
e.Node.ChildNodes.Add(node)
Next
End Sub
What I'd like to be able to be able to do is figure out a (clean) way to
filter out the directories before adding them as nodes to the treeview. For
example, a few things I'd like to do is prevent some specified directories
from showing up entirely, or allow the user to only go a certain depth in
some specified directory. I realize I could code all of this logic directly
in the PopulateNode class, but I don't feel like it's very clean to hard code
a bunch of strings into my script. I was thinking I might somehow be able to
utilize an XML file, but I don't know how. Something along these lines,
perhaps:
<root>
<dir name="folder1" hidden="true" />
<dir name="folder2" maxDepth="3" />
<dir name="folder3">
<dir name="subFolder1" maxDepth="1" />
<dir name="subFolder2" hidden="true" />
</dir>
</root>
Would the best thing to do be to have some kind of filter method that goes
through the XML file and looks for the node to be added before adding it to
the treeview? Or am I taking the wrong approach to this?

Thank you for your time.
Jul 3 '08 #1
0 1386

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

Similar topics

3
by: serge calderara | last post by:
Dear all, I have a csv file data which has been read and populate on a dataset object. then I need to bind part of the content of the dataset to a treeview control. I have read that XML format...
3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
0
by: Henry | last post by:
I am trying to create a TreeView control that works with an ADO Dataset DataTable or the new BindingSource stuff in .NET 2.0 to build a Treeview that is populated. This is what I came up with...
2
by: JUAN ERNESTO FLORES BELTRAN | last post by:
Hi you all, I am developping a python application which connects to a database (postresql) and displays the query results on a treeview. In adittion to displaying the info i do need to implement...
3
by: Shawn Ramirez | last post by:
As with most web applications speed is a huge deal to me in my applications. My customers don't really care if my app is a true 3 tier application or not, they just want it to be faster then it was...
3
by: Harry Haller | last post by:
Hello, I want to implement a generic list which will be used to display 7 columns in a GridView. One should be able to sort, filter and page each of the 7 columns. Ideally the filter should be...
1
by: echuck66 | last post by:
Hi, I have a Winforms 2.0 project that I'm working on that involves populating a treeview control from data contained in a fairly large dataset that has to be refreshed periodically. I have no...
0
by: =?Utf-8?B?SmVmZiBHYW8=?= | last post by:
Hi, I am working on an asp.net web application that uses treeview control to display hierarchical data from an xml data source. When I changed the xml data source the treeview doesn’t update...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.