Delphi-Listview+;OwnerData=按键时发出嘟嘟声

Delphi-Listview+;OwnerData=按键时发出嘟嘟声,delphi,listview,virtual,Delphi,Listview,Virtual,对于使用OwnerData(虚拟)的TListView,当我按下LV作为activecontrol的键时,它会发出嘟嘟声。如何避免这种情况?控件可能试图对列表数据执行搜索,以查找与您键入的文本匹配的项。您是否实现了OnDataFind事件?正如Remy Lebeau所说,问题是OnDataFind没有实现,但您应该这样实现它: procedure TForm1.ListViewDataFind(Sender: TObject; Find: TItemFind; const FindString:

对于使用OwnerData(虚拟)的TListView,当我按下LV作为activecontrol的键时,它会发出嘟嘟声。如何避免这种情况?

控件可能试图对列表数据执行搜索,以查找与您键入的文本匹配的项。您是否实现了
OnDataFind
事件?

正如Remy Lebeau所说,问题是
OnDataFind
没有实现,但您应该这样实现它:

procedure TForm1.ListViewDataFind(Sender: TObject; Find: TItemFind; const FindString: string;
  const FindPosition: TPoint; FindData: Pointer; StartIndex: Integer; Direction: TSearchDirection;
  Wrap: Boolean; var Index: Integer);
begin
  // Here we must find currently selected element
  if Assigned((Sender as TListView).Selected) then
    Index := (Sender as TListView).Selected.Index;
end;

我现在听到了,但嘟嘟声仍然出现。而且,在FindData触发之后,索引似乎总是-1?(即使它真的找到了什么)。谢谢,这样就不用发出嘟嘟声了。在这里问一些与此相关的问题可以吗,还是我现在接受并提出一个新问题?(如何检索找到的数据的项索引)。我不确定FindData是否真的在这里工作,因为它会用任何键触发(我在按键时调用FindCaption)