Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2012.01.29;
Скачать: [xml.tar.bz2];

Вниз

"Правильная " сортировка чисел в ListBox   Найти похожие ветки 

 
Laguna ©   (2011-10-21 16:39) [0]

Подскажите, есть ли  некий алгоритм сортировки чисел в Listbox чтобы они были представлены в правильном порядке. После установки Sort := True;, всеравно получается
...
102
20
92
...


 
Dennis I. Komarov ©   (2011-10-21 16:43) [1]

Напиши алгоритм сам и используй его...


 
Ega23 ©   (2011-10-21 16:43) [2]

Ты не числа, а строки сортируешь. Сортируй числи. Ну или 0 добавляй вперде.


 
Dennis I. Komarov ©   (2011-10-21 16:47) [3]

Пардон, я сперва ListView...


 
Юрий Зотов ©   (2011-10-21 16:48) [4]

ListBox содержит СТРОКИ, а не числа. Поэтому он и сортирует их как СТРОКИ, а не как числа.

А насчет "есть ли алгоритм" - конечно есть. Например, добавлять нули в начало каждой строки до тех пор, пока ее длина не станет равной длине самой длинной строки:
020
092
102


 
Медвежонок Пятачок ©   (2011-10-21 16:56) [5]

TStringList.CustomSort(MySortFunction)
+
ListBox1.Items.Assingn(SortedStringList);


 
Laguna ©   (2011-10-21 17:00) [6]

Это понятно что строки сортирую. Вот Нашел в нэте пример добавления пробелов до общей дины (http://forum.ixbt.com/post.cgi?id=print:26:32395)- не прокатило. С нулями думаю должно получиться, к тому же скорее всего числа и будут с лидирующими нулями.


 
DiamondShark ©   (2011-10-21 17:43) [7]

WM_COMPAREITEM Notification

--------------------------------------------------------------------------------

The system sends the WM_COMPAREITEM message to determine the relative position of a new item in the sorted list of an owner-drawn combo box or list box. Whenever the application adds a new item, the system sends this message to the owner of a combo box or list box created with the CBS_SORT or LBS_SORT style.

Syntax

WM_COMPAREITEM

   WPARAM wParam
   lpCompareItem = (LPCOMPAREITEMSTRUCT) lParam;
   
Parameters

wParam
Specifies the identifier of the control that sent the WM_COMPAREITEM message.
lpCompareItem
Pointer to a COMPAREITEMSTRUCT structure that contains the identifiers and application-supplied data for two items in the combo or list box.
Return Value

The return value indicates the relative position of the two items. It may be any of the values shown in the following table.

Value Meaning
-1 Item 1 precedes item 2 in the sorted order.
0 Items 1 and 2 are equivalent in the sorted order.
1 Item 1 follows item 2 in the sorted order.

Remarks

When the owner of an owner-drawn combo box or list box receives this message, the owner returns a value indicating which of the items specified by the COMPAREITEMSTRUCT structure will appear before the other. Typically, the system sends this message several times until it determines the exact position for the new item.

If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. The DWL_MSGRESULT value set by the SetWindowLong function is ignored.


 
DiamondShark ©   (2011-10-21 17:50) [8]

Как вариант lbVirtual
и возвращать данные из внешнего хранилища в нужном порядке.



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2012.01.29;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.003 c
4-1254333344
EPaul
2009-09-30 21:55
2012.01.29
Как запустить программу пользователем SYSTEM


2-1319031742
Fr
2011-10-19 17:42
2012.01.29
группировка Items в TListView Delphi 7


8-1222045702
Dispoz
2008-09-22 05:08
2012.01.29
Попытка загрузить картинку


1-1282812225
Vidog
2010-08-26 12:43
2012.01.29
Упаковка файлов и архивация


2-1318866159
Gu
2011-10-17 19:42
2012.01.29
Установка VersionInfo





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский