TreeNode Image

T

Tom

I have your classic WinForm treeview that uses an image list with 2 images:
1. An open folder.
2. A closed folder.

The events that I have registered for are:
1. afterselect
2. afterexpand
3. aftercollapse

The AfterExpand and AfterCollapse events set the imageindex appropriately,
and seems to be working fine. However, here's my prob:

If I expand a folder, and then click a subdirectory under that folder, and
then go back and click on the parent folder (which is still expanded) the
folder icon reverts back to the closed folder icon, when it should still be
the open folder icon.

I know the afterexpand and aftercollapse events do not get fired.
AfterSelect of course gets fired, but after stepping through the code, the
TreeNode has the appropriate image index (1) at the beginning and end of the
function right before it returns.

My TreeNode's are not exactly TreeNode's of the TreeNode class. I created
my own class that derives from TreeNode and has an ArrayList inside of it.
I can't imagine that the inheritance is screwing this up somehow, but that's
my guess at this point.

Can anybody see something that I'm doing wrong?

Thanks.
 
J

Jeff Gaines

If I expand a folder, and then click a subdirectory under that folder, and
then go back and click on the parent folder (which is still expanded) the
folder icon reverts back to the closed folder icon, when it should still
be the open folder icon.
[snipped]

Can anybody see something that I'm doing wrong?

Perhaps just your expectations? TreeNodes have an ImageIndex and
SelectedImageIndex and you can only select one node at any time. I
appreciate that the flags for getting the selected image is something like
TVM_OPENICON but that's a bit misleading.
 
T

Tom

Jeff Gaines said:
If I expand a folder, and then click a subdirectory under that folder, and
then go back and click on the parent folder (which is still expanded) the
folder icon reverts back to the closed folder icon, when it should still
be the open folder icon.
[snipped]

Can anybody see something that I'm doing wrong?

Perhaps just your expectations? TreeNodes have an ImageIndex and
SelectedImageIndex and you can only select one node at any time. I
appreciate that the flags for getting the selected image is something like
TVM_OPENICON but that's a bit misleading.

Geeze. Thanks Jeff.
 

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