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;
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With