treeview image behavior

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have a very odd behaving treeview. i use image list with a bunch of icons
and as nodes get added to a tree i assign image index to each node.
everething works fine, no problems there. now, when i click on any node it's
icon changes to icon with index 0 in image list, and as i move to another
node the original image comes back. i have no events handling in code, so
this is a mistery.
 
Have you remembered to set each TreeNode's SelectedImageIndex property as
well as its ImageIndex?
Chris Jobson
 
well, it is set, but what im trying to do is to keep image unchanged even if
it is selected. i can specify what image it will have but i have 5 diferent
icons for various items and wnat o keep then unchaged
 
The following code to add nodes works correctly for me (in this case my
image list has 4 images):

for (int i = 0; i < 4; ++i) {
TreeNode n = new TreeNode("Node with image " + i.ToString());
n.ImageIndex = i;
n.SelectedImageIndex = i;
treeView1.Nodes[0].Nodes.Add(n);
}

but if I remove the "n.SelectedImageIndex = i;" line I get the behaviour you
describe.

Chris Jobson
 
thanks, works, and makes sense. got to pay more attension to all this
properties:)

Chris Jobson said:
The following code to add nodes works correctly for me (in this case my
image list has 4 images):

for (int i = 0; i < 4; ++i) {
TreeNode n = new TreeNode("Node with image " + i.ToString());
n.ImageIndex = i;
n.SelectedImageIndex = i;
treeView1.Nodes[0].Nodes.Add(n);
}

but if I remove the "n.SelectedImageIndex = i;" line I get the behaviour you
describe.

Chris Jobson

gremlin321 said:
well, it is set, but what im trying to do is to keep image unchanged even
if
it is selected. i can specify what image it will have but i have 5
diferent
icons for various items and wnat o keep then unchaged
 
Back
Top