15,885,546 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by brunofer2007 (Top 3 by date)
brunofer2007
15-Jan-12 5:59am
View
Deleted
just replace the logical comparison "n.Text[0] < temp.Text[0]" with other comparison logical.
It have to be a TreeNode property.
brunofer2007
14-Sep-11 6:36am
View
Deleted
1 - Sometimes a TreeView doesn't have necessarily a datasource. The nodes could be added manually (that was my case).
2 - If you watch carefully the code, you see that recursive function it's only called when a node has childnodes:
foreach (TreeNode n in node.ChildNodes)
sort(n);
the recursive function is called as many child nodes you have, so you can predict the number of iterations
3 - I'll explain this step to you:
- temp variable is initialized to null.
- for each child node: if the temp is null, temp = childnode.
if temp != null,
if the first character of childNode < fisrt character of Temp, temp = childNode
- when you reach the end of for each statment, the Temp variable has the lowest start character node.
- add that node to List "childs", this way the list will be filled alphabetically.
- delete temp node from child node.
- start all over again (the temp variable is set to null to store again the lowest start letter node).
- this cycle stops when there are no more childnodes:
while(node.ChildNodes.Count>0)
- then, you simply add again the childnode in the node (alphabetically sorted):
foreach (TreeNode a in childs)
node.ChildNodes.Add(a);
4 - and finally, as I mention before, the sort() method for TreeView is not present on WebForms (ASP.NET).
brunofer2007
12-Sep-11 4:21am
View
Deleted
Hello George,
as you can see in the title, this solution is for ASP.NET TreeView control.
The method you mentioned works fine in WinForms Controls, but it's not present on this WebForm control.