Frank
Your example work ok on Delphi7. Tomrrow i will try it on Turbo Explorer
over my programm.
Thanks
Frank Reynolds :
Pablo,
Here is some code you can try
It is the Unit and DFM files for a very simple test I was doing
It should come up and work as it is, but if not, then add in some more
data
Cheers,
Frank
>I have tried many examples, so I must doing something wrong .
>I am working on the virtuallistview example of turbo explorer (the same
>of delphi 7) an I need to click on the column header and
>sort the list for that column like the Window$ explorer.
>>
>Thanks
>>
>>
>Rob Kennedy :
>>
>
>
pablo gietz wrote:
I can't sort the column in a listview. I have tried the examples and
doesn't work.
What examples have you tried? In what ways did they not work? What were
you expecting to happen, and what happened instead?
http://www.catb.org/~esr/faqs/smart-questions.html#bespecific
http://www.catb.org/~esr/faqs/smart-questions.html#beprecise
unit LV_u;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TForm1 = class(TForm)
ListView1: TListView;
procedure ListView1ColumnClick(Sender: T; Column: TListColumn);
procedure FormActivate(Sender: T);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
o : boolean;
implementation
{$R *.DFM}
function MySortProc(Item1, Item2 : TListItem; ParamSort: Integer):
integer; stdcall;
var t1, t2 : string;
begin
case ParamSort of
0 : begin
t1 := Item1.Caption;
t2 := Item2.Caption;
end;
14 : begin
t1 := Item1.SubItems[ParamSort-1];
t2 := Item2.SubItems[ParamSort-1];
end;
end;
if o then
result := lstrcmp(PChar(t1), PChar(t2))
else
result := -lstrcmp(PChar(t1), PChar(t2));
end;
procedure TForm1.ListView1ColumnClick(Sender: T;
Column: TListColumn);
begin
ListView1.CustomSort(@MySortProc, Column.Index);
o := not o;
end;
procedure TForm1.FormActivate(Sender: T);
begin
o := true;
end;
end.
object Form1: TForm1
Left = 192
Top = 107
Caption = 'List View Sorting Test'
ClientHeight = 266
ClientWidth = 427
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
C = False
Activate = FormActivate
PixelsPerInch = 96
TextHeight = 13
object ListView1: TListView
Left = 16
Top = 48
Width = 409
Height = 150
Columns = <
item
Caption = 'No'
Width = 30
end
item
Caption = 'Name'
Width = 90
end
item
Caption = 'Addr1'
Width = 90
end
item
Caption = 'Addr2'
Width = 90
end
item
Caption = 'Town'
Width = 90
end>
Items.ItemData = {
FFFFFFFFFFFFFFFFFFFFFFFF}
T = 0
ViewStyle = vsReport
ColumnClick = ListView1ColumnClick
end
end
Delphi-Talk mailing list -Delphi-Talk (AT) elists (DOT) org
avast! Antivirus: Saliente mensaje limpio.
Base de datos de Virus (VPS): 000754-2, 05/07/2007
Comprobado en: 6/7/2007 12:06:04 a.m.
avast! tiene los derechos reservados (c) 2000-2007 ALWIL Software.
http://www.avast.com
Delphi-Talk mailing list -Delphi-Talk (AT) elists (DOT) org