user1593881
user1593881

Reputation:

Delphi ListView OnSelectItem fires twice

ListView's OnSelectItem event fires twice. ListView is virtual in VsReport mode. How to prevent this behavior or is there a better workaround?

Upvotes: 1

Views: 1231

Answers (1)

bummi
bummi

Reputation: 27384

The event is firing for selection and unselection. If node X was selected and you select node Y it will report:

  1. node X selected=false
  2. node Y selected=true

You can make the behavior visible by :

procedure TForm5.ListView1SelectItem(Sender: TObject; Item: TListItem;
  Selected: Boolean);
begin
  Showmessage(Item.Caption +' - '+IntToStr(Integer(Selected)));
end;

If you want to react only on selection just evaluate Selected.

Upvotes: 6

Related Questions