Anyone out there today? Happy Thanksgiving!
I am writing a Window app that has a TreeView control. I am creating the
nodes dynamically from an XML file, and I have some icon images that I have
associated with each of the "top" nodes. The users, after some usability
testing, have decided they don't want the "child" nodes to have any icons
associated.
I cannot seem to get the child nodes to NOT have an icon. I have tried
changing the index of the ImageControl the nodes are pointing to to a -1,
commenting out the assignment, etc. but they end up using the image at index
0. Here's the relevent code:
//...switch statement above this to figure out which icon index to put in
currentIcon
tempSysNode.ImageIndex = currentIcon;
sysTree.Nodes.Add(tempSysNode);
node = tempSysNode;
categoryIdentifier = tempSysInfo.systemName;
}
// Add SubSystem nodes to the TreeView, under their respective System name
currentIcon = -1; //One of the many tests
TreeNode tempSubsysNode = new TreeNode(tempSysInfo.subsystemName);
tempSubsysNode.Tag = tempSysInfo.ID;
//tempSubsysNode.ImageIndex = currentIcon; //I'VE TRIED COMMENTING THIS OUT
BUT IT DEFAULTS TO INDEX 0 WHEN I DO
node.Nodes.Add(tempSubsysNode);
DataRow newRow = systemsDataSet.Tables[0].NewRow();
//More code to figure out if there are any grandchild nodes
How do I eliminate the icons for all of the child, grandchild, etc. nodes?
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
Robbe Morris [C# MVP] - 20 Nov 2006 17:33 GMT
Just create a blank icon and stick it in your image list.

Signature
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
> Anyone out there today? Happy Thanksgiving!
>
[quoted text clipped - 37 lines]
> aka Gandalf
> MCSD.NET, MCAD, MCT
WhiteWizard - 20 Nov 2006 18:12 GMT
Thanks Robbe but that ends up leaving a icon sized blank space after the +
but before the text. One of the reasons for taking the icons out is to
shorten that text so not so much of it goes behind the splitter we have on
the form.
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
> Just create a blank icon and stick it in your image list.
>
[quoted text clipped - 39 lines]
> > aka Gandalf
> > MCSD.NET, MCAD, MCT
Robbe Morris [C# MVP] - 20 Nov 2006 22:29 GMT
If memory serves me correctly, the tree is going to
render that way in order to line things up.
I don't recall the build in .net TreeView supporting
the concept of some nodes having icons and
some don't.

Signature
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/adonet_source_code_generator.asp
> Thanks Robbe but that ends up leaving a icon sized blank space after the +
> but before the text. One of the reasons for taking the icons out is to
[quoted text clipped - 57 lines]
>> > aka Gandalf
>> > MCSD.NET, MCAD, MCT