Avoiding the display of an image on treeview node
Hello,
i work under the following environment: WinXP, CSharpDevelop under .NET 2.0.
Problem description:
To simplify it, I'm trying to make a single node on a treeView. The treeview is linked to an imageList which contains some images. I wanted to show the treeview node without images. It seems not to be working in design time and in runtime.
The code is as follow:
Code:
node = new TreeNode(strValue);
node.Tag = "BTN" + intNextNode.ToString()+";0;;";
tV.Nodes.Add(node);
node.ImageIndex = -2;
node.SelectedImageIndex = -2;
The result is always the same, it shows the first item of the imageList when nothing is selected and no image when the node is selected.
How do i do to have this node without images?
Thx for your patience.
Re: Avoiding the display of an image on treeview node
Hmm ... it seems that an underflow value isn't working , it will always choose the first picture in the image collection . Try instead an overflow index .
Code:
node.ImageIndex = 200;
node.SelectedImageIndex = 200;
where I supposed you don't have 200 pictures in the collection :)
Re: Avoiding the display of an image on treeview node
I used an underflow value because it is how it was generate in the *.Designer.cs when i add a node manually, giving the 2 proprieties, ImageIndex and SelectedImageIndex, the value of "(NONE)".
In this case, the image displayed was the first image added to the imageList object.
With your suggestion, the node displays the last image added to the imageList object.
Maybe i should load a transparent gif as first image... :confused:
I just thought there was a way...
Thx for your suggestion!
Re: Avoiding the display of an image on treeview node
Not completly satisfactory, but adding a transparent picture to the imageList previous to all other images solves the problems.
Re: Avoiding the display of an image on treeview node
I used the overflow value and worked on my machine