Hello,
I found also that NxComboBox does not have the property <Sorted>. It's a question of compatibility between the original ComboBox and the new one. My question is - if such property does not exist, shell I manually sort my Items or this is build into the component.
Best regards
Luben
NxComboBox does not have property Sorted
Started by Luben, Oct 22 2006 10:40 AM
6 replies to this topic
#1
Posted 22 October 2006 - 10:40 AM
#2
Posted 22 October 2006 - 10:45 AM
Hello Luben,
I will add this property. I will try to add it in first next release, or before with providing here a single function code.
regards
I will add this property. I will try to add it in first next release, or before with providing here a single function code.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 22 October 2006 - 10:53 AM
Hello,
>>I will add this property. I will try to add it in first next release, or before with providing here a single function code.
It's complex function - when you add items and the property Sorted is True the new Item goes to the proper position, so you have to shift all Items up/down to free space for the new one. In case if you have 2000 records and the procedure is not optimized it can take long time to complete.
But better is to have something that could be tested.
Best regards
Luben
>>I will add this property. I will try to add it in first next release, or before with providing here a single function code.
It's complex function - when you add items and the property Sorted is True the new Item goes to the proper position, so you have to shift all Items up/down to free space for the new one. In case if you have 2000 records and the procedure is not optimized it can take long time to complete.
But better is to have something that could be tested.
Best regards
Luben
#4
Posted 22 October 2006 - 11:02 AM
Hello Luben,
It may be done quickly with QuickSort. Also, adding new items in sorted array it will be fast. But, you are right, I will test it this more.
regards
It may be done quickly with QuickSort. Also, adding new items in sorted array it will be fast. But, you are right, I will test it this more.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#5
Posted 22 October 2006 - 11:52 AM
QUOTE (Boki (Berg) @ Oct 22 2006, 12:02 PM) <{POST_SNAPBACK}>
Hello Luben,
It may be done quickly with QuickSort. Also, adding new items in sorted array it will be fast. But, you are right, I will test it this more.
regards
It may be done quickly with QuickSort. Also, adding new items in sorted array it will be fast. But, you are right, I will test it this more.
regards
Hi Boki,
Be carefull when using quicksort as it tends to keep swapping items when it's already sorted. It's best to use only when you set all items with th etext property. When doing add, methods like just doing a binary search and insert it at the right spot will always be faster than quicksort. Even bubblesort can be faster than (bidirectional) quicksort if the items are already sorted and you only need to add & position a single item.
G.W. van der Vegt
#6
Posted 22 October 2006 - 12:27 PM
Hello Wim,
Yes, I will need to catch when FItems are changed (Add, Insert, Delete...) and then do a proper action. I only worry that TStrings don't have such events to be overriden (Add, Delete...) so I will need to derrive new TStrings class from TStrings and then directly override desired methods.
regards
Yes, I will need to catch when FItems are changed (Add, Insert, Delete...) and then do a proper action. I only worry that TStrings don't have such events to be overriden (Add, Delete...) so I will need to derrive new TStrings class from TStrings and then directly override desired methods.
regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#7
Posted 22 October 2006 - 02:40 PM
Hi Boki,
Quite some work!
You could also have perhaps a more simple approach. Have a simple DoSort method that need to be called which does a low performance sort (ie. one without swapping equal values).
Then in my option if you have a 2000 items combobox there is perhaps somethign wrong with the UI design (the ComboBox just isn't suitable for that amount of data) and it's perhaps such a special case the programmer could insert them sorted him/herself. In other words don't bother adding it.
I'm not sure if I ever posted it here but I have developed a external sort class that sorts without knowing what it sorts, it only uses indexes and calls an OnCompare/OnSwap handler. It features selectable sorting methods (QuickSort, BubbleSort, ShellSort & Coctailsort).
Let me know if your interested. If turned into a VCL it could be handy for implementing multiple column sorting in NextGrid too.
QUOTE (Boki (Berg) @ Oct 22 2006, 01:27 PM) <{POST_SNAPBACK}>
Yes, I will need to catch when FItems are changed (Add, Insert, Delete...) and then do a proper action. I only worry that TStrings don't have such events to be overriden (Add, Delete...) so I will need to derrive new TStrings class from TStrings and then directly override desired methods.
Quite some work!
You could also have perhaps a more simple approach. Have a simple DoSort method that need to be called which does a low performance sort (ie. one without swapping equal values).
Then in my option if you have a 2000 items combobox there is perhaps somethign wrong with the UI design (the ComboBox just isn't suitable for that amount of data) and it's perhaps such a special case the programmer could insert them sorted him/herself. In other words don't bother adding it.
I'm not sure if I ever posted it here but I have developed a external sort class that sorts without knowing what it sorts, it only uses indexes and calls an OnCompare/OnSwap handler. It features selectable sorting methods (QuickSort, BubbleSort, ShellSort & Coctailsort).
Let me know if your interested. If turned into a VCL it could be handy for implementing multiple column sorting in NextGrid too.
G.W. van der Vegt
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











