Delphi Sources

Сортировка ListView в режиме vsReport при нажатии на заголовок колонки



Автор: MBo

На выходных с подругой в постели интимничаю, а перед глазами - ник(!!!!) девчушки одной с обаятельной лексикой и дефектной мыльницей (поэтому фотки её у меня нет).... Ну, думаю, это уже из разряда "пора остановиться"...


function CustomDateSortProc(Item1, Item2: TListItem; ParamSort: integer):
  integer; stdcall;
begin
  result := 0;
  if strtodatetime(item1.SubItems[0]) > strtodatetime(item2.SubItems[0]) then
    Result := 1
  else if strtodatetime(item1.SubItems[0]) < strtodatetime(item2.SubItems[0])
    then
    Result := -1;
end;

function CustomNameSortProc(Item1, Item2: TListItem; ParamSort: integer): integer
  item.Caption := sr.name;
  Item.SubItems.Add(datetimetostr(filedatetodatetime(sr.time)));
end;
until FindNext(sr) < > 0;
FindClose(sr);
end;

procedure TForm1.lv1ColumnClick(Sender: TObject; Column: TListColumn);
begin
  if column = lv1.columns[0] then
    LV1.CustomSort(@CustomNameSortProc, 0)
  else
    LV1.CustomSort(@CustomDateSortProc, 0)
end;


Copyright © 2004-2025 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте