Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi VirtualStringTree - IncrementalSearch (https://www.delphipraxis.net/42521-virtualstringtree-incrementalsearch.html)

karl der große 20. Mär 2005 11:03


VirtualStringTree - IncrementalSearch
 
Hallo!

Hat jemand von Euch eine Ahnung wie IncrementalSearch beim VirtualStringTree funktioniert.

Hat vielleicht jemand einige Code-Schnippsel.

Danke

Albi 20. Mär 2005 12:07

Re: VirtualStringTree - IncrementalSearch
 
Hallo,

wie das genau funtzt kann ich dir nicht sagen aber Du kannst Dir ja mal bei Mike Lischke die Online Dokumentation zur VirtualStringTree anschauen.

Diese liegt als PDF und HTML-Format vor. Wenn Du dir PDF herunterlädst, schau dir die Seite 383 an, da sollte Dir weitergeholfen werden.

generic 20. Mär 2005 12:50

Re: VirtualStringTree - IncrementalSearch
 
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.

karl der große 20. Mär 2005 15:07

Re: VirtualStringTree - IncrementalSearch
 
Das Beispiel hab ich schon gefunden, aber ich versteh eigentlich das ganze Kapitel nicht, kann mir da jemand vielleicht mit einem eigenen Beispiel helfen??

Gruss Karl

DP-Maintenance 20. Mär 2005 17:35

DP-Maintenance
 
Dieses Thema wurde von "Daniel" von "Datenbanken" nach "VCL-Komponenten und Controls" verschoben.

generic 21. Mär 2005 12:37

Re: VirtualStringTree - IncrementalSearch
 
im string wird übergeben was du eingegeben hast.
als ergebnis lieferst du (Result) ob der "node"-Wert größer, kleine oder gleich dem "text" ist.

von node musst du eigendlich nur den wert ermitteln der genutzt werden soll.
im normalfall ist das der text der in baum ausgegeben wird.

wenn das immer noch nicht ausreichen sollte poste ich ein beispiel...

ratloser 8. Jan 2006 21:54

Re: VirtualStringTree - IncrementalSearch
 
kannst du mir mal ein beispiel posten

Danke


Alle Zeitangaben in WEZ +1. Es ist jetzt 08:39 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz