Recent

Author Topic: [SOLVED] Icon of TTreeNode vanishes when node is selected  (Read 3871 times)

EganSolo

  • Sr. Member
  • ****
  • Posts: 398
[SOLVED] Icon of TTreeNode vanishes when node is selected
« on: December 20, 2021, 12:00:46 am »
Like the title says: I've got a TTreeView with a bunch of nodes. Each node has an associated icon loaded from an image list.

Whenever a node is selected, I see the node's text but the icon vanishes.

The nodes are added programmatically as follows:

Code: Pascal  [Select][+][-]
  1.    aNode := TreeView.Items.Add(Nil, 'Some Text');
  2.    aNode.ImageIndex := 10; //Could be any index in the image list
  3.  

I've got the following options set:
Code: Pascal  [Select][+][-]
  1.    tvoHideSelected := false;
  2.    tvoHotTrack     := True;
  3.    tvoReadOnly     := True;
  4.    tvo_ShowButtons := false;
  5.    tvo_ShowLines   := false;
  6.    tvo_ShowRoot    := false;
  7.  

What am I missing?

Thanks
« Last Edit: December 24, 2021, 03:24:28 am by EganSolo »

wp

  • Hero Member
  • *****
  • Posts: 13504
Re: Icon of TTreeNode vanishes when node is selected
« Reply #1 on: December 20, 2021, 01:04:52 am »
You must also assign the SelectedIndex of the node:
Code: Pascal  [Select][+][-]
  1. aNode := TreeView.Items.Add(Nil, 'Some Text');
  2. aNode.ImageIndex := 10; //Could be any index in the image list
  3. aNode.SelectedIndex := aNode.ImageIndex;

EganSolo

  • Sr. Member
  • ****
  • Posts: 398
Re: [SOLVED] Icon of TTreeNode vanishes when node is selected
« Reply #2 on: December 24, 2021, 03:24:45 am »
Thanks wp! That did it.

 

TinyPortal © 2005-2018