Treenode Images

G

Guest

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
 
R

Robbe Morris [C# MVP]

Just create a blank icon and stick it in your image list.

--
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
 
G

Guest

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


Robbe Morris said:
Just create a blank icon and stick it in your image list.

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





WhiteWizard said:
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
 
R

Robbe Morris [C# MVP]

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.

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





WhiteWizard said:
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


Robbe Morris said:
Just create a blank icon and stick it in your image list.

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





WhiteWizard said:
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
 

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