TreeView: Sorted Method dont work

  • Thread starter Thread starter Michael
  • Start date Start date
M

Michael

Hello,

The "Sorted" Method of a TreeView control dont work.
How can I make it work?

I know that I can sort the data that will compose the
nodes before, then add the nodes from the sorted result
after. Adding a sort function in the code will also add
more time delay in the execution.

But since there already is a sort method, I would like to
use it.


Dim objTree As TreeView

objTree.Sorted = True


Thanks,

Michael
 
Hi,
Here is some info on the Sorted property.
First, you have to set the property AFTER you've
added the nodes. Anyway, here is a snippet from Help:

The Sorted property can be used in two ways: first, to sort the Node objects at

the root (top) level of a TreeView control and, second, to sort the immediate children of any individual Node object.

For example, the following code sorts the root nodes of a TreeView control:

Private Sub Command1_Click()
TreeView1.Sorted = True ' Top level Node objects are sorted.
End Sub
The next example shows how to set the Sorted property for a Node object as it is created:

Private Sub Form_Load()
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(,,,"Parent Node")
nodX.Sorted = True
End Sub
Setting the Sorted property to True sorts the current Nodes collection only.

When you add new Node objects to a TreeView control, you must set the Sorted property to

True again to sort the added Node objects.
 
Hello Again!

It works! The TreeView was sorted. Thanks.
I dont have help installed for these types of controls.

Also,

Thanks for putting me in the right path for the other
issue: "pointers used in VB".

I found an example that showed me how to do "Linked List
in VB", which is what I was looking for:

http://www.freevbcode.com/ShowCode.asp?ID=6512

http://www.freevbcode.com/ShowCode.asp?ID=6511


Thanks,

Michael


-----Original Message-----
Hi,
Here is some info on the Sorted property.
First, you have to set the property AFTER you've
added the nodes. Anyway, here is a snippet from Help:

The Sorted property can be used in two ways: first, to sort the Node objects at

the root (top) level of a TreeView control and, second,
to sort the immediate children of any individual Node
object.
For example, the following code sorts the root nodes of a TreeView control:

Private Sub Command1_Click()
TreeView1.Sorted = True ' Top level Node objects are sorted.
End Sub
The next example shows how to set the Sorted property for
a Node object as it is created:
Private Sub Form_Load()
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(,,,"Parent Node")
nodX.Sorted = True
End Sub
Setting the Sorted property to True sorts the current Nodes collection only.

When you add new Node objects to a TreeView control, you
must set the Sorted property to
True again to sort the added Node objects.


--
HTH
Dan Artuso, Access MVP


"Michael" <[email protected]> wrote in
message news:[email protected]...
 
Back
Top