VirtualStringTree and PaintText lazarus / 21-General ---------------------------------------------------------------------- bobonwhidbey · 2021-06-13 17:58 I'm just starting to learn about all the amazing capabilities of TVirtualStringTree. I think a whole book might be written on it with all it's properties and options. I'd like to be able to "paint" the text area. I was hoping that something like this in onPaintText would work. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Data := VST.GetNodeData(Node);    TargetCanvas.TextOut(x,y,Data.Text); In this manner I could have some of the text in one color, and some in another. I also need to stop the text from being painted by the component. ---------------------------------------------------------------------- winni · 2021-06-13 18:20 Hi! Look at  the example page of VirtualTreeView and look at the onPaintText section: https://wiki.freepascal.org/VirtualTreeview_Example_for_Lazarus Winni ---------------------------------------------------------------------- balazsszekely · 2021-06-13 18:23 @bobonwhidbey QuoteI'm just starting to learn about all the amazing capabilities of TVirtualStringTree. I think a whole book might be written on it with all it's properties and options. I'd like to be able to "paint" the text area. I was hoping that something like this in onPaintText would work.Try something like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  PData = ^TData;  TData = record    FBold: Boolean;    FColored: Boolean;  end; procedure TForm1.VSTPaintText(Sender: TBaseVirtualTree;  const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;  TextType: TVSTTextType);var  Data: PData;begin  if TextType <> ttNormal then    Exit;  Data := VST.GetNodeData(Node);  case Column of    -1: begin //if no columns are defined, the case is not needed       if Data^.FBold then           TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];          if Data^.FColored then         if Node = Sender.FocusedNode then             TargetCanvas.Font.Color := VST.Colors.SelectionTextColor           else             TargetCanvas.Font.Color := clRed;       end;    0: begin         //each column has different font       end;    end;end; procedure TForm1.Button1Click(Sender: TObject);var  Node: PVirtualNode;  Data: PData;begin  Node := VST.AddChild(nil);  Data := VST.GetNodeData(Node);  Data^.FBold := True;  Data^.FColored := False;   Node := VST.AddChild(nil);  Data := VST.GetNodeData(Node);  Data^.FBold := False;  Data^.FColored := True;end; ---------------------------------------------------------------------- bobonwhidbey · 2021-06-13 18:45 The examples and GetMem's approach seem to require that the text for the entire column must use the same font attributes. I want to have some text in one color/style and other parts of the text in another. ---------------------------------------------------------------------- balazsszekely · 2021-06-13 18:54 @ bobonwhidbey QuoteThe examples and GetMem's approach seem to require that the text for the entire column must use the same font attributes. I want to have some text in one color/style and other parts of the text in another. If you wish to have full control over the drawing then VirtualDrawTree is a much better option. You can find an example in the following post(see attachment): https://forum.lazarus.freepascal.org/index.php/topic,37834.msg257241.h tml#msg257241 Please check the VDTDrawNode event.