Page 1 of 1

Disabling of a StateImage for one Node

Posted: 21 Jan 2009, 12:49
by Natorion
Hi,

Is it possible to easily disable a the display of a StateImage of one Node or is the only way the use of a custom StateImage-List with one "blank" image?

cheers,
Natorion

Re: Disabling of a StateImage for one Node

Posted: 21 Jan 2009, 16:25
by TiKu
Using a custom state image list is one way to achieve this. Another one is to use the CustomDraw event. But a custom state image list should be faster and easier.

Re: Disabling of a StateImage for one Node

Posted: 22 Jan 2009, 12:12
by Natorion
After I realized that a blank icon is not really what I want (it is a white space next to the expando) I tried setting the StateImageIndex to Empty:

Code: Select all

treeItem.StateImageIndex = Empty
It is exactly what I want ;)

Re: Disabling of a StateImage for one Node

Posted: 22 Jan 2009, 16:04
by TiKu
Oh, yes, I had forgot about this possibility. You can replace Empty with 0, because this is what is happening behind the scenes. For treeviews, state images are one-based, that's why 0 doesn't result in the first state image being displayed.
I tested your code on Windows Vista and it works - with themes as well as without themes. But you should test it on Windows 2000 and XP. If I remember correctly, not all versions of comctl32.dll move the item text to the left if the state image is set to 0.

Re: Disabling of a StateImage for one Node

Posted: 23 Jan 2009, 11:00
by Natorion
Tested it with XP without theming and works fine.

Re: Disabling of a StateImage for one Node

Posted: 23 Jan 2009, 11:12
by TiKu
I've tested it on Windows 2000 and it works there, too. So I think I'll document it.
Maybe it was Windows 98 or NT 4.0 where it didn't work. But those systems aren't supported anymore.