Delphi – TListView column sort (sorted by the first two columns)

I use Delphi 2010 and TListView to list names and other data. The first two columns are Last Name&Name

Caption = Last Name
SubItems[0] = First Name

How to sort ListView by these two columns? These are just the columns that Listview will sort by column, I want to always keep the sorting (when adding, editing, deleting items)

How can I do this?

Set SortType to’stBoth’, and implement the OnCompare event handler. Example:

procedure TForm1.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
var
S1, S2: string;
begin
S1 := Item1.Caption;
if Item1.SubItems.Count> 0 then
S1 := S1 + Item1.SubItems[ 0];
S2 := Item2.Caption;
if Item2.SubItems.Count> 0 then
S2 := S2 + Item2.SubItems[0];

Compare := CompareText(S1, S2);
end;

I use Delphi 2010 and TListView to list names and other data. The first two columns are Last Name&Name

Caption = Last Name
SubItems[0] = First Name

How to pass this To sort ListView by two columns? These are just the columns that Listview will sort by column, I want to always keep the sorting (when adding, editing, deleting items)

How can I do this?

Set SortType to’stBoth’ and implement the OnCompare event handler. Example:

< pre>procedure TForm1.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
var
S1, S2: string;
begin
S1 := Item1.Caption;
if Item1.SubItems.Count> 0 then
S1 := S1 + Item1.SubItems[0];
S2 := Item2. Caption;
if Item2.SubItems.Count> 0 then
S2 := S2 + Item2.SubItems[0];

Compare := CompareText(S1, S2);< br />end;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3112 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.