Home › Forums › Konopka Signature VCL Controls (formerly Raize Components) › tRzTreeView change node font
- This topic has 1 reply, 2 voices, and was last updated 2021-07-16 at 5:22 pm by
Ray Konopka.
-
AuthorPosts
-
-
July 12, 2021 at 1:15 pm #2534
I need to be able to change the font color and style on certain nodes in the TreeView. I’ve searched the internet without any luck. Can someone point me in the correct direction? TIA
-
July 16, 2021 at 5:22 pm #2538
Hi Jay,
The TRzTreeView is a descendant of the TTreeView and inherits the same properties and events. Specifically, you can do some customizations by handle the OnAdvancedCustomDrawItem event.
For example, I created a test app where I dropped a TRzTreeView on the form. I then added a FormCreate event handler, and an event handler for the tree view’s OnAdvancedCustomDrawItem event.
procedure TForm11.FormCreate(Sender: TObject); var Node: TTreeNode; begin Node := RzTreeView1.Items.Add( nil, 'One' ); RzTreeView1.Items.AddChild( Node, 'AAAA' ); RzTreeView1.Items.AddChild( Node, '1111' ); Node := RzTreeView1.Items.Add( nil, 'Two' ); RzTreeView1.Items.AddChild( Node, 'BBBB' ); RzTreeView1.Items.AddChild( Node, '2222' ); Node := RzTreeView1.Items.Add( nil, 'Three' ); RzTreeView1.Items.AddChild( Node, 'CCCC' ); RzTreeView1.Items.AddChild( Node, '3333' ); RzTreeView1.FullExpand; end; procedure TForm11.RzTreeView1AdvancedCustomDrawItem( Sender: TCustomTreeView; Node: TTreeNode; State: TCustomDrawState; Stage: TCustomDrawStage; var PaintImages, DefaultDraw: Boolean); begin if Node.Text = 'AAAA' then RzTreeView1.Canvas.Font.Color := clRed else if Node.Text = 'BBBB' then RzTreeView1.Canvas.Font.Color := clBlue else RzTreeView1.Canvas.Font.Color := clBlack; end;When you run the app, you will see the AAAA and BBBB in their respective colors.
Hope this helps.Ray
-
-
AuthorPosts
- You must be logged in to reply to this topic.