Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VirtualStringTree: Search for a text where type is not a String

I would like to implement a search procedure to a VirtualStringTree and I would like to do it by comparing the search text with the text from node and not from the pointer (eg. Data^.Column0) because this is not always as String.

Please help me with a suggestion to get back the text from node as it is.

For a better understanding see bellow code (I adjust an example from Lazarus)

type
  PTreeData = ^TTreeData;
  TTreeData = record
    Column0: TDate; //Date
    Column1: Integer; //Integer
    Column2: String;
  end;

procedure TForm1.VSTGetText(Sender: TBaseVirtualTree; Node: PVirtualNode;
 Column: TColumnIndex; TextType: TVSTTextType; var CellText: WideString);
var
  Data: PTreeData;
begin
  Data := VST.GetNodeData(Node);
  case Column of
    0: CellText := DateToStr(Data^.Column0); //2015-05-11 or 11-05-2015
    1: CellText := IntToStr(Data^.Column1) + ' days'; //22 days
    2: CellText := Data^.Column2;
  end;
end;
like image 339
REALSOFO Avatar asked Feb 12 '26 05:02

REALSOFO


1 Answers

If you want to get a virtual tree view cell text, then you can use the Text property. That will internally trigger the OnGetText event and you'll be able to obtain the text just like you are returning it to display in the tree:

var
  S: string;
  Node: PVirtualNode;
  Column: TColumnIndex;
begin
  ...
  S := VirtualStringTree.Text[Node, Column];
end;
like image 180
TLama Avatar answered Feb 15 '26 09:02

TLama



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!