Home »» Delphi [Programming]
Thread Profile: ListView
ListView
Hi
I can't sort the column in a listview. I have tried the examples and
doesn't work.
Any complete example?
Thanks
avast! Antivirus: Saliente mensaje limpio.
Base de datos de Virus (VPS): 000753-2, 03/07/2007
Comprobado en: 3/7/2007 10:24:30 p.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
I can't sort the column in a listview. I have tried the examples and
doesn't work.
Any complete example?
Thanks
avast! Antivirus: Saliente mensaje limpio.
Base de datos de Virus (VPS): 000753-2, 03/07/2007
Comprobado en: 3/7/2007 10:24:30 p.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
- 5Answer
- Total
at [2008-5-6 19:54:16]
Hi Pablo,
From memory, there are some examples if ListView in Torry <www.torry.net>
Do a search, also look in tVCL - List and Tree Views for samples and
in Tips - search on Listview and sort
If you can't find anything, please let me know, and I can post a sample
I am leaving the house for a few hours, but will be back in about 8 hours
Frank
Hi
I can't sort the column in a listview. I have tried the examples and
doesn't work.
Any complete example?
Thanks
>
>
>
Delphi-Talk mailing list -Delphi-Talk (AT) elists (DOT) org
From memory, there are some examples if ListView in Torry <www.torry.net>
Do a search, also look in tVCL - List and Tree Views for samples and
in Tips - search on Listview and sort
If you can't find anything, please let me know, and I can post a sample
I am leaving the house for a few hours, but will be back in about 8 hours
Frank
Hi
I can't sort the column in a listview. I have tried the examples and
doesn't work.
Any complete example?
Thanks
>
>
>
Delphi-Talk mailing list -Delphi-Talk (AT) elists (DOT) org
- 1No.
- Answer
at [2008-5-6 19:55:20]
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
- 2No.
- Answer
at [2008-5-6 19:56:13]
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
avast! Antivirus: Saliente mensaje limpio.
Base de datos de Virus (VPS): 000754-1, 04/07/2007
Comprobado en: 4/7/2007 11:03:08 p.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
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
avast! Antivirus: Saliente mensaje limpio.
Base de datos de Virus (VPS): 000754-1, 04/07/2007
Comprobado en: 4/7/2007 11:03:08 p.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
- 3No.
- Answer
at [2008-5-6 19:57:14]
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
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
- 4No.
- Answer
at [2008-5-6 19:58:24]
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
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
- 5No.
- Answer