Hi!
I'm looking for a way to add multiple icons to the treeview item (for example 3). It's possible ?
2 replies to this topic
#1
Posted 19 October 2010 - 04:44 AM
|
|
|
#2
Posted 23 October 2010 - 02:17 PM
It is possible, to do this you'll need to add some variables and system usages,
We will need to create an "ImageList" which will store all our images.
An ImageList is a supporting control that is typically used by other controls, such as a ListView but is exposed as a component to developers. We can use this component in our applications when we are building our own controls such as a photo gallery or an image rotator control.
Once that is declared, We can begin with the adding of the images to the lsit.
Next we need to createa a Root Node,
In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked nodes, The root node being the main structure.
Now we need to create some Child Nodes,
A child node or descendant node is a node in a tree data structure that is linked to by a parent node or root node. Thinking of the tree as a directed graph, node A is a child of node B if and only if node A is a sucessor node of B.
And finally we need to add some Sibling Nodes,
The end result...

(The images are not mine, I found them in a tutorial a few years ago)
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data;
We will need to create an "ImageList" which will store all our images.
ImageList iList = new ImageList();
An ImageList is a supporting control that is typically used by other controls, such as a ListView but is exposed as a component to developers. We can use this component in our applications when we are building our own controls such as a photo gallery or an image rotator control.
Once that is declared, We can begin with the adding of the images to the lsit.
iList.Images.Add(new Icon("Image0.ico"));
iList.Images.Add(new Icon("Image1.ico"));
iList.Images.Add(new Icon("Image2.ico"));
// iList.Images.Add(new Icon("Image3.ico"));
treeView1.ImageList = iList ;
Next we need to createa a Root Node,
TreeNode rootNode = treeView1.Nodes.Add("Root Node");
rootNode.ImageIndex = 0;
In computer science, a tree is a widely-used data structure that emulates a hierarchical tree structure with a set of linked nodes, The root node being the main structure.
Now we need to create some Child Nodes,
TreeNode child1 = rootNode.Nodes.Add("Child Node 1");
child1.ImageIndex = 1;
TreeNode child2 = rootNode.Nodes.Add("Child Node 2");
child2.ImageIndex = 1;
A child node or descendant node is a node in a tree data structure that is linked to by a parent node or root node. Thinking of the tree as a directed graph, node A is a child of node B if and only if node A is a sucessor node of B.
And finally we need to add some Sibling Nodes,
TreeNode child = child1.Nodes.Add("Sibling Node");
child.ImageIndex = 2;
child = chiListd1.Nodes.Add("Sibling Node 1");
child.ImageIndex = 2;
child = child1.Nodes.Add("Sibling Node 2");
child.ImageIndex = 2;
child = child2.Nodes.Add("Sibling Node");
childd.ImageIndex = 2;
child = child2.Nodes.Add("Sibling Node 1");
child.ImageIndex = 2;
child = child2.Nodes.Add("Sibling Node 2");
child.ImageIndex = 2;
The end result...

(The images are not mine, I found them in a tutorial a few years ago)
#3
Posted 26 December 2010 - 02:35 AM
I thinking about three icons associated to one element (node) of three.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









