Logo video2dn
  • Сохранить видео с ютуба
  • Категории
    • Музыка
    • Кино и Анимация
    • Автомобили
    • Животные
    • Спорт
    • Путешествия
    • Игры
    • Люди и Блоги
    • Юмор
    • Развлечения
    • Новости и Политика
    • Howto и Стиль
    • Diy своими руками
    • Образование
    • Наука и Технологии
    • Некоммерческие Организации
  • О сайте

Скачать или смотреть How to : Sorting a tlistview by the column clicked by the user

  • How to : Tips and Trick
  • 2019-02-07
  • 13
How to : Sorting a tlistview by the column clicked by the user
column clickedthe
  • ok logo

Скачать How to : Sorting a tlistview by the column clicked by the user бесплатно в качестве 4к (2к / 1080p)

У нас вы можете скачать бесплатно How to : Sorting a tlistview by the column clicked by the user или посмотреть видео с ютуба в максимальном доступном качестве.

Для скачивания выберите вариант из формы ниже:

  • Информация по загрузке:

Cкачать музыку How to : Sorting a tlistview by the column clicked by the user бесплатно в формате MP3:

Если иконки загрузки не отобразились, ПОЖАЛУЙСТА, НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если у вас возникли трудности с загрузкой, пожалуйста, свяжитесь с нами по контактам, указанным в нижней части страницы.
Спасибо за использование сервиса video2dn.com

Описание к видео How to : Sorting a tlistview by the column clicked by the user

Sorting a tlistview by the column clicked by the user

How to sort a ListView in ascending or descending order by a given column?

Sorting a TListView by the column clicked by the user

We want the following behaviour for a ListView:



When the user clicks on a column header, the ListView should be sorted by that column





The initial sort order should be ascending. If the user clicks on the same column again, the sort order should be toggled. If the user clicks on another column, the sort order of the new column should be the same as the last sorted column.



For the implementation we need two variables to hold the last column clicked by the user and the current sort order:

var

LastSortedColumn: integer;

Ascending: boolean;

We can initialize them when the form is created:

procedure TForm1.FormCreate(Sender: TObject);

begin

LastSortedColumn := -1;

Ascending := True;

end;

In the ColumnClick event of the ListView we determine the sort order and perform the sort:

procedure TForm1.ListView1ColumnClick(Sender: TObject;

Column: TListColumn);

begin



if Column.Index = LastSortedColumn then

Ascending := not Ascending

else

LastSortedColumn := Column.Index;

TListView(Sender).CustomSort(@SortByColumn, Column.Index);

end;

SortByColumn is a function that should be previously declared and is the function used by CustomSort to compare two items. The value passed to the Data parameter of CustomSort will be passed as the Data parameter to SortByColumn and we use it for the sort column:

function SortByColumn(Item1, Item2: TListItem; Data: integer):

integer; stdcall;

begin

if Data = 0 then

Result := AnsiCompareText(Item1.Caption, Item2.Caption)

else

Result := AnsiCompareText(Item1.SubItems[Data-1],

Item2.SubItems[Data-1]);

if not Ascending then Result := -Result;

end;

You can find the full source code of this article in the archive that accompanies the Pascal Newsletter #25

Комментарии

Информация по комментариям в разработке

Похожие видео

  • О нас
  • Контакты
  • Отказ от ответственности - Disclaimer
  • Условия использования сайта - TOS
  • Политика конфиденциальности

video2dn Copyright © 2023 - 2025

Контакты для правообладателей [email protected]