Показать сообщение отдельно
  #1  
Старый 28.09.2011, 21:28
Кодер Кодер вне форума
Активный
 
Регистрация: 25.02.2008
Сообщения: 395
Репутация: -599
По умолчанию Сортировка в ListView

Сортировка в ListView (vsReport) по клику на шапке столбца.

Гугл:
Код:
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; stdcall;
begin
Result := CompareText(Item1.Caption,Item2.Caption);
end;
procedure TForm1.GetFilesClick(Sender: TObject);
var sr:tsearchrec;
Item: TListItem;
begin
if FindFirst('e:\*.*',faAnyFile, sr) = 0 then repeat
     if (sr.Attr and faDirectory) <> sr.Attr then
     begin
       item:=lv1.items.add;
       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; 

Ругается на CustomNameSortProc и CustomDateSortProc([DCC Error] uMain.pas(172): E2036 Variable required)

*процедуры описал в паблике юнита.
Ответить с цитированием