473,394 Members | 1,887 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,394 software developers and data experts.

TreeView: Sort Dynamically?

Are there TreeViews that can be sorted on-the-fly? i.e. that can be sorted
without reloading them?
--
PeteCresswell
Aug 31 '06 #1
2 5941
You need to store all the node names in an Array or a table. I think
the table would be easier.

First clear all the nodes - or only clear the desired nodes.

Me.Treeview0.Nodes.Clear

Then re-add the nodes from the table in the order that you want. By
storing the Node names in a table you can use sql to sort the nodes.

Dim RS As DAO.Recordset
Set RS = CurrentDB.OpenRecordset("Select Keys, Relatives, NodeText From
tblNodes Order By Nodes DESC")

You can sort subsets this way too. You clear only subnodes under a main
node, then re-add the subnodes to the main node. This will only work
with a properly normalized table. You have to associate each childnode
with a ParentNode in the table. It is hierarchical.

Main1, submain1, sub1
Main1, submain1, sub2
Main1, submain1, sub3
Main1, submain2, sub1
Main1, submain2, sub2
Main1, submain2, sub3
Main2, submain1, sub1
Main2, submain1, sub2
Main2, submain1, sub3
...

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 31 '06 #2

http://www.vbaccelerator.com/home/VB...ol/article.asp

or
http://tinyurl.com/p5jrv
I've just tested it and it works fine in Access.

It has a Movenode method which alows you to (strangely enough) move nodes
around.

This is the first time I've tried it so the codes probably a bit rough but
the following:-

Private Sub Command1_Click()
Dim tvw As vbalTreeView
Dim nodTop As cTreeViewNode
Dim nodSub As cTreeViewNode
Dim nodSubSub As cTreeViewNode
Dim children As cTreeViewNodes
Dim subChildren As cTreeViewNodes

Set tvw = Me.vbalTreeView0.Object

Set nodTop = tvw.Nodes.Add(, etvwFirst, "xxx")
nodTop.Text = "1111"

Set children = nodTop.children

Set nodSub = children.Add(, etvwChild, "yyyy")
nodSub.Text = "2222"

Set subChildren = nodSub.children

Set nodSubSub = subChildren.Add(, etvwChild, "zzzz")
nodSubSub.Text = "3333"

End Sub

Added three nodes in the following configuration

1111
|____ 2222
|____ 3333

Then the following code

Private Sub Command2_Click()
Dim tvw As vbalTreeView
Dim nodTop As cTreeViewNode
Dim nodSub As cTreeViewNode
Dim nodSubSub As cTreeViewNode
Dim children As cTreeViewNodes
Dim subChildren As cTreeViewNodes

Set tvw = Me.vbalTreeView0.Object

Set nodTop = tvw.Nodes("xxx")
Set children = nodTop.children

Set nodSub = children.Item("yyyy")
Set subChildren = nodSub.children

Set nodSubSub = subChildren.Item("zzzz")

Call nodSubSub.MoveNode(nodTop, etvwChild)
End Sub

Moved node 3333 to the folowing configuration

1111
|____ 2222
|____ 3333

--

Terry Kreft
"(PeteCresswell)" <x@y.Invalidwrote in message
news:oc********************************@4ax.com...
Are there TreeViews that can be sorted on-the-fly? i.e. that can be
sorted
without reloading them?
--
PeteCresswell

Aug 31 '06 #3

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

Similar topics

42
by: lauren quantrell | last post by:
So many postings on not to use the treeview control, but nothing recently. Is it safe to swim there yet with Access 2000-Access 2003?
3
by: Ed Sutton | last post by:
I need to do a custom sort on a TreeView. I have various object types associated with the TreeNode Tag property. I want to sort objects of the same type at the top of the list, other objects at...
3
by: Alan | last post by:
Hi all, Besides the Sorted property, the TreeView control in .Net FCL doesn't provide application-defined sort. But I put several kinds of data into the treeview, and hope to sort them...
0
by: Chris Bowring | last post by:
Alan, the easiest way to sort a TreeView is to: * add the nodes to an ArrayList * sort the ArrayList with an IComparer * remove the nodes from the TreeView and add them back from the...
2
by: Aaron Corcoran | last post by:
I posted this under the webcontrols area as well, however, I didn't receive any feedback, so please pardon my redundant post. Dear Group, My coworker has been working on a project that uses...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
4
by: Sam | last post by:
Hi, How can I sort the root nodes of a treeview according to a integer stored in their tag property? I want to do that at run time on a button's click event. Thank you
1
by: kvicky | last post by:
I am trying to load child nodes to a TreeNode in a TreeView in a ASP.net web application. The Treeview with parent nodes are loaded on a Page_load while doing if( ! ISPostback ) and then in the...
0
by: uncensored | last post by:
Hi, Sort of new with the whole treeview control and I was wondering is there a way to build a treeview menu using my SQL data I pull from a database instead of having to hard code it into the...
3
by: =?Utf-8?B?TGVzbGll?= | last post by:
Using Visual Studio 2005 SP1 I am attempting to dynamically load a treeview control. I create an XmlDataSource and then load the data source using XmlDataSource.Data. I Load my XML string into...
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: 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...
0
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...
0
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...
0
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...

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.