Recent

Author Topic: TreeView - how to make some items bold/italic?  (Read 3990 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2386
    • UVviewsoft
TreeView - how to make some items bold/italic?
« on: January 02, 2018, 11:09:02 am »
i dont see that TTreeNode has props for Bold/italic/underline.
how to paint some nodes in such way?

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: TreeView - how to make some items bold/italic?
« Reply #1 on: January 02, 2018, 11:23:47 am »
You have to custom draw the node using TTreeView's OnAdvancedCustomDraw event property.

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: TreeView - how to make some items bold/italic?
« Reply #2 on: January 02, 2018, 01:56:08 pm »
i dont see that TTreeNode has props for Bold/italic/underline.
how to paint some nodes in such way?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView;
  2.   Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
  3. var
  4.   LFont: TFont;
  5. begin
  6.   LFont := Sender.Canvas.Font;
  7.   if Odd(Node.AbsoluteIndex) then
  8.     LFont.Style := LFont.Style + [fsBold]
  9.   else
  10.     LFont.Style := LFont.Style - [fsBold];
  11.   if (Node.AbsoluteIndex mod 3) = 0 then
  12.     LFont.Style := LFont.Style + [fsUnderline]
  13.   else
  14.     LFont.Style := LFont.Style - [fsUnderline];
  15. end;

 

TinyPortal © 2005-2018