Delphi - Listview + OwnerData =在Keypress上发出哔哔声

时间:2012-11-12 18:38:33

标签: delphi listview virtual

使用Ownerist(虚拟)的TListView,当我按下LV作为activecontrol的键时,它会发出BEEP声音。我怎么能避免这种情况?

2 个答案:

答案 0 :(得分:3)

正如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;

答案 1 :(得分:2)

控件可能会尝试搜索列表数据,以查找与您键入的文本匹配的项目。您是否实施了OnDataFind活动?