treeview image behavior

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.
 
C

Chris Jobson

Have you remembered to set each TreeNode's SelectedImageIndex property as
well as its ImageIndex?
Chris Jobson
 
G

Guest

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
 
C

Chris Jobson

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top