VirtualStringTree: search for text where the type is not a string

I would like to apply the search procedure to VirtualStringTree

, and I would like to do this by comparing the search text with the text from the node, not the pointer (for example Data^.Column0

), because that is not always the case String

.

Please help me with a suggestion to return the text from node as is.

For a better understanding, see the following code (I'm setting up 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;

      

+3


source to share


1 answer


If you want to get the text of a cell of the virtual tree, you can use the property Text

. This will internally trigger an event OnGetText

and you should be able to get the text in the same way you return it to be displayed in the tree:



var
  S: string;
  Node: PVirtualNode;
  Column: TColumnIndex;
begin
  ...
  S := VirtualStringTree.Text[Node, Column];
end;

      

+3


source







All Articles