Einzelnen Beitrag anzeigen

generic

Registriert seit: 24. Mär 2004
Ort: bei Hannover
2.416 Beiträge
 
Delphi XE5 Professional
 
#3

Re: VirtualStringTree - IncrementalSearch

  Alt 20. Mär 2005, 13:50
easy...

IncrementalSearch := isAll;

schon ist an. wenn du auf die suche genauer reagieren möchtest dann musst du das OnIncrementalSearch Ereignis erweitern.

die onlinehilfe beschreibt das ganz gut, zusammengefasst funktioniert das wie eine normale suche.

This event is integral part of the incremental search functionality (see also Keyboard, hotkeys and incremental search). It is triggered during search for a node which matches the given string. Similar to other compare routines return a value < 0 if the node's caption is considered as being before the given text, = 0 if it is the same and > 0 if it is considered being after the given text.



Delphi-Quellcode:
procedure TfrmProperties.VST3IncrementalSearch(Sender: TBaseVirtualTree; Node: PVirtualNode; const Text: WideString;
  var Result: Integer);

var
  S, PropText: string;


begin
  // Note: This code requires a proper Unicode/WideString comparison routine which I did not want to link here for
  // size and clarity reasons. For now strings are (implicitly) converted to ANSI to make the comparison work.
  // Search is not case sensitive.
  S := Text;
  if Node.Parent = Sender.RootNode then
  begin
    // root nodes
    if Node.Index = 0 then
      PropText := 'Description'
    else
      PropText := 'Origin';
  end
  else
  begin
    PropText := PropertyTexts[Node.Parent.Index, Node.Index, ptkText];
  end;

  // By using StrLIComp we can specify a maximum length to compare. This allows us to find also nodes
  // which match only partially.
  Result := StrLIComp(PChar(S), PChar(PropText), Min(Length(S), Length(PropText)))
end;
Notes
Usually incremental search allows to match also partially. Hence it is recommended to do comparison only up to the length

of the shorter string.
  Mit Zitat antworten Zitat