Solved

TreeView Sorting

Posted on 2007-03-31
12
1,620 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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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 50 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 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