« Reply #1 on: January 09, 2012, 02:54:01 PM »
Hi,
You have two ways to go here:
1) Use tree.StateImages collection of images to define icons for expanded and collapsed nodes with children:
tree.StateImages.GroupCollapsed = myIconForCollapsedNode;
Note that you have an option to define icons only for expanded or collapsed nodes disregarding of other node`s parameters (under the mouse cursor, etc.).
2) Other way is to virtualize bound property, i.e. supply the bound property value dynamically in run-time:
var img = new NodeImage();
img.AttachTo(tree);
img.DataFieldName = "myField";
img.VirtualMode = true;
var tb = new NodeTextBox();
tb.AttachTo(tree);
var node = new Node("test");
node.AttachTo(tree);
tree.NodeControlValueGet += tree_NodeControlValueGet;
bool tree_NodeControlValueGet(FlexibleTreeView pTreeview, NodeControlValueEventArgs pArgs)
{
if (pArgs.FieldName == "myField")
{
pArgs.Value = pArgs.Node.IsHot ? Resources.HotIcon : Resources.GeneralIcon;
return true;
}
return false;
}
Key code pieces here are img.VirtualMode = true and tree_NodeControlValueGet(...) where you return images according to the node state.
If you choose second approach, please don`t return icons right from your resources instance (Resources.HotIcon)! Cache them and then return because it will slow down your tree because of frequent calls.