1

This thread discussed using different colors of text in the same node of a Virtual Treeview.

I like especially variant C (white text in rounded red rectangle), but I want it displayed as ttStatic, not in an own column - is that possible?

Tom
  • 11
  • 1

1 Answers1

0

You can write the following code in the event "OndrawText":

procedure TForm2.vstDrawText(Sender: TBaseVirtualTree; TargetCanvas: TCanvas;
  Node: PVirtualNode; Column: TColumnIndex; const Text: string;
  const CellRect: TRect; var DefaultDraw: Boolean);
var ss1,ss2:string; POS:Integer;  fc:TColor;fs:Integer;
begin
  case Column of
    0,1,3:
    begin
      //First, store the default font size and color number
      fc:=TargetCanvas.Font.Color;
      fs:=TargetCanvas.Font.Size;
      DefaultDraw:=false;
      ss1:=Text.Substring(0,3);
      ss2:=Text.Substring(3);
      pos:=5;
      TargetCanvas.Font.Color:=clRed;
      TargetCanvas.Font.size:=fs+2;
      TargetCanvas.TextOut(CellRect.left+POS,4,ss1);
      pos:=pos+targetcanvas.TextWidth(ss1)+2;
      TargetCanvas.Font.Color:=fc;
      TargetCanvas.Font.size:=fs;
      TargetCanvas.TextOut(CellRect.left+POS,5,ss2);
    end;
  end;
end;
luohq
  • 1