A better listview ?

From: Skybuck Flying (nospam_at_hotmail.com)
Date: 02/23/04


Date: Mon, 23 Feb 2004 15:24:47 +0100

Hi

I need a better listview for finding items...

Custom's ListView FindData is a bit stupid... it only compares pointers..

It could for example compare strings...

Since I am not really a component person... I wonder how much work it is to
create a new TmyListview

put it on the component palette and override the finddata...

Is that possible without to much hassle ?!

function TCustomListView.FindData(StartIndex: Integer; Value: Pointer;
  Inclusive, Wrap: Boolean): TListItem;
var
  I: Integer;
  Item: TListItem;
begin
  Result := nil;
  if Inclusive then Dec(StartIndex);
  for I := StartIndex + 1 to Items.Count - 1 do
  begin
    Item := Items[I];
    if (Item <> nil) and (Item.Data = Value) then
    begin
      Result := Item;
      Exit;
    end;
  end;
  if Wrap then
  begin
    if Inclusive then Inc(StartIndex);
    for I := 0 to StartIndex - 1 do
    begin
      Item := Items[I];
      if (Item <> nil) and (Item.Data = Value) then
      begin
        Result := Item;
        Exit;
      end;
    end;
  end;
end;

Bye,
  Skybuck.