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

Specific IComparer use with TreeNodeCollection

Hello.
I am trying to use a specific IComparer object to sort the nodes of my
TreeView. Now if it was an Array I could simply call Sort() and pass it
my IComparer object. But with the TreeNodeCollection object there is no
sort method.

Can anyone give me some ideas on how to implement this?
Thanks

May 11 '06 #1
3 4547
Have you tried using the TreeViewNodeSorter property on the TreeView
class?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<es********@hotmail.com> wrote in message
news:11**********************@q12g2000cwa.googlegr oups.com...
Hello.
I am trying to use a specific IComparer object to sort the nodes of my
TreeView. Now if it was an Array I could simply call Sort() and pass it
my IComparer object. But with the TreeNodeCollection object there is no
sort method.

Can anyone give me some ideas on how to implement this?
Thanks

May 11 '06 #2
Unfortunately we're not using .NET 2.0 so that property is not
available yet.

May 11 '06 #3
If that is the case, then you are going to have to implement it
yourself. You will have to insert/remove all of the items in the list in
the order you wish to sort them.

I would recommend performing the sorting before you attach the nodes to
the trees, to cut down on the number of repaints of the control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<es********@hotmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
Unfortunately we're not using .NET 2.0 so that property is not
available yet.

May 11 '06 #4

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

Similar topics

3
by: Cybertof | last post by:
Hello, Could someone please explain me the difference between the 2 interfaces IComparable and IComparer ? In which cases use one or the other ? Are they dedicated to own classes or built-in...
0
by: | last post by:
I have derived new classes for the TreeNode and TreeView classes that Microsoft provides. Since the TreeNodeCollection class is sealed I created my own class that implements the IList interface....
4
by: Chuck Bowling | last post by:
I have a serialized TreeNodeCollection that I want to initialize a TreeView with. Is there a simple assignment I can use for this or do I have to iterate thru the collection and add individual...
2
by: Dmitriy Kolesnik | last post by:
Hello, All! I have next problem: I need to override TreeNodeCollection method Add(), but I know that I can't inherited from TreeNodeCollection. How I can resolve this problem? Help me please...
0
by: Patrick.O.Ige | last post by:
I have this code below. All its suppose to do is to EXPAND / COLLAPSE ALL of my treeview. But when i use ASP.NET WEbmatrix it all works fine .. But with VS.NET is says TreeNodeCollection not...
10
by: INeedADip | last post by:
I am trying to use a generic (reflection) IComparer class to sort a generic list but I get the error: Unable to cast object of type 'GenericComparer' to type 'System.Collections.Generic.Icomparer...
2
by: engelit.junk | last post by:
Hi, If you look at TreeNodeCollection.Find Method, you'll see: Finds the tree nodes with specified key, optionally searching subnodes. public TreeNode Find ( string key, bool...
1
by: Brett Romero | last post by:
What are the reasons to use one over the other? SortedList implements IComparer.Compare(). Why would you also want to create a SortedList class that implements IComparable.CompareTo()? I know...
3
by: jtfaulk | last post by:
Re: ArrayList, Sort, Menu, IComparer, Object, multidemensional I have a multi-dimensional arraylist, and I would like to sort one level of it but not all. The multi-dimensional arraylist...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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,...
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.