Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TreeView Sorting

Posted on 2007-03-31
12
Medium Priority
?
1,624 Views
Last Modified: 2013-11-23
Hi

I have a TreeView of Years and Months and I want to sort it probebly. I am using the alphasot method and it's working for the years but it's mixing up the months order , so how can i solve this problem.
please help.

thanks
0
Comment
Question by:ibrobar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 3
  • 2
12 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18828263
can you draw how the treeview is / should be organized?
also, how do you fill it?
0
 

Author Comment

by:ibrobar
ID: 18828271
Hi Angelll

I am filling the treeview from a table.
my tree is as follow :
Library
     2000
         Jan
         Feb
         Mar
    2001
         Jan
         Feb

and so on
so if I add new year like 1974 should goes first and if i add new month should  be the last node

thanks
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18828292
i fear that with D programming, that is not possible, except removing and readding all other child nodes at that level in the correct order...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:ibrobar
ID: 18828312
I think if we use the CustomSort procedure it will help but i am not sure how
0
 

Author Comment

by:ibrobar
ID: 18841579
Hi

so no solution upto now , please somebody help.
Is it possible that i cann't do two sorting on one tree , one sort for level one nodes and the other is for level two nodes

regards
0
 
LVL 1

Expert Comment

by:swiatlo
ID: 18849525
Sort items using TStringList.
Add string formated as 'yyyymm' ( '200100','200101'..'200112') and objects (pointers to nodes or structured information).
Use
TStringList.AddObject(const S: string; AObject: TObject )
set TStringList.Sort:=true

0
 

Author Comment

by:ibrobar
ID: 18855519
Hi Swiatlo

THanks for your help but could you please write me the code cause I never dealt with TstringList and I will increase the points if you gave me an accpeted solution
0
 
LVL 1

Expert Comment

by:swiatlo
ID: 18856824
I just came to a second solution.
Why not add nodes in format 'YYYYMM', Run AlphaSort and then replace all
YYYYMM to proper strings that
'200100' will become a year '2001',
'200105' will become a month 'May'
0
 

Author Comment

by:ibrobar
ID: 18862538
Hi Swiatlo

I read your new solution, but if I applied the alphasort it will sort the month belonging to each year in alphabetic sorting like April will be the first and this my problem in the first place cause i wanna the months to be sorted in it's real order not in alphabetic one

regards
0
 
LVL 1

Accepted Solution

by:
swiatlo earned 150 total points
ID: 18862881
AlphaSort will end up with order

200100  //2001
  200102 //Feb
  200104 //Apr
  200105 //May
200200
200300
  200304
  200311
...
...
and after sort  replace those strings with Aprils, Mays and what ever you like
0
 

Author Comment

by:ibrobar
ID: 18863157
Hi Swiatlo

I will try it today and i will let you know , it a kind of misleading but clever way.

thanks
0
 

Author Comment

by:ibrobar
ID: 18868781
Hi again Swiatlo

Actullay I used part of your solution , you gave me the idea.
I used a field I called it Mask , and i put in it 200100 when my year field is 2001 and so on like below
 Mask     // year
200100  // 2001
200102  // Feb
200104  // Apr
200105  / /May
But I added to this (instead of Replacing those strings with Aprils, Mays) I used secondary index on the field Mask so my tree came sorted in the way i want when i loaded to the treeview using the field year.

any way thanks a lot and best regards.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question