View previous topic :: View next topic |
Author |
Message |
gigi
Joined: 20 May 2007 Posts: 1
|
Posted: Sun May 20, 2007 4:12 am Post subject: Using icons in TreeView |
|
|
Hi all.
I'm new here and I still do not have great experience with DFL, so it can be that my following question is simply ""stupid"" ...
I'm using DFL for a project and I was trying to use the teeview component. It works ok but I was not able to find a way to add icons to tree nodes (and maybe a method to specify a different icon per node level).
Is this supposed to be implemented or not?
If not, is there a simple way to do that without changing the DFL internals (I do not know, by simply creating a "child" treeview and overrinding some methods?)
Thanks very much! |
|
Back to top |
|
|
Chris Miller
Joined: 27 Mar 2004 Posts: 514 Location: The Internet
|
Posted: Wed May 23, 2007 4:51 am Post subject: Re: Using icons in TreeView |
|
|
It's not supported yet, sorry. It's planned to be implemented soon.
It involves image lists. Each TreeNode has a handle (HTREEITEM) with which you can attempt to do it yourself if you can't wait.
- Chris |
|
Back to top |
|
|
GencoreOperative
Joined: 04 Oct 2009 Posts: 3
|
Posted: Tue Oct 13, 2009 8:54 am Post subject: |
|
|
Hello,
Related to the original post, I have followed the dirlistview.d example shipped with 0.9.8 and have adapted it for the TreeView control. My objective is to display an icon against each item in the TreeView.
The example I have included below appears to display some strange behaviour which I am unable to work out. The first node in the tree does not display an icon. The child node of the first, displays an icon only when selected.
Does anyone have an idea what I am doing wrong in this code?
Thanks!
Code: | import dfl.all;
class TreeDemo: dfl.form.Form {
TreeView tree;
this() {
text = "Tree Demo";
clientSize = Size(250, 200);
dockPadding.all = 5;
tree = new TreeView();
tree.dock = DockStyle.FILL;
tree.parent = this;
tree.itemHeight = 32;
load ~= &form_load;
}
private void form_load(Object sender, EventArgs ea) {
ImageList imageList = new ImageList();
imageList.imageSize = Size(32, 32);
imageList.colorDepth = ColorDepth.DEPTH_32BIT;
Resources ires = new Resources("shell32.dll");
imageList.images.add(ires.getIcon(3, true));
imageList.images.add(ires.getIcon(4, true));
tree.imageList = imageList;
TreeNode root = new TreeNode();
root.text = "Hello";
tree.nodes.add(root);
root.imageIndex = 3;
TreeNode next = new TreeNode();
next.text = "World";
tree.nodes[0].nodes.add(next);
next.imageIndex = 4;
}
}
int main()
{
int result = 0;
try {
Application.enableVisualStyles();
Application.run(new TreeDemo());
} catch(Object o) {
msgBox(o.toString(), "Fatal Error", MsgBoxButtons.OK, MsgBoxIcon.ERROR);
result = 1;
}
return result;
} |
|
|
Back to top |
|
|
GencoreOperative
Joined: 04 Oct 2009 Posts: 3
|
|
Back to top |
|
|
|