I've got a custom list that I'm binding to the tree, which works fine. I don't want checkboxes throughout every level of the tree, I just want checkboxes on the nodes at the LAST level (last descendant).
At the moment, I'm able to handle the InitializeDataNode event, and see the nodes being initialized. When a node's ListObject happens to be of a specific type (my custom type), I set the Override property of that node, like this:
private void ultraTree1_InitializeDataNode(object sender, Infragistics.Win.UltraWinTree.InitializeDataNodeEventArgs e) { if (e.Node.ListObject is MyObject) { e.Node.Override = _over; } }
The _over object is just a class-level Override, which looks like this:
_over.NodeStyle = NodeStyle.CheckBox;
PROBLEM IS.... even though I can see the Override property being set, the checkbox never shows up in my tree. Any ideas?
Thanks guys!
I just needed to set the CellClickAction
treeHierarchy.Override.CellClickAction =
CellClickAction.EditCell;
One issue was never resolved. Why is the CheckBox not editable?
I've added an unbound checkbox using the same approach, and I can't check the checkbox.
What you are saying seems great for a bound column, but I was trying to create an unbound column containing a checkbox.
I worked around this issue. Since I have total control of the data bound to the tree, I simply added a boolean property to the necessary object. That eliminated the effort involved with the "unbound" column, and gave me a nice checkbox. With a bit of magic (making the column editable, CellClickAction, etc), it works just fine.
Setting the CheckEditor's CheckState property does not set the check state for each node. You have to use the UltraTreeNode.SetCellValue method to do that. The "...state that is neither checked nor unchecked..." is just that, the indeterminate state. Since no cell value was set, it defaults to null, which in a three-state checkbox is depicted as CheckState.Indeterminate.
You can handle the InitializeDataNode event to set initial property values of a node that comes into being via data binding, like so:
private void ultraTree1_InitializeDataNode(object sender, InitializeDataNodeEventArgs e){ if ( e.Node.DisplayColumnSetResolved.Columns.Exists("SPCHECKCOLUMN") ) e.Node.SetCellValue( e.Node.DisplayColumnSetResolved.Columns["SPCHECKCOLUMN"], CheckState.Unchecked );}
Thanks again Mike.
I've made heavy use of the NodeLevelOverrides for the first few levels of the tree, and it worked great. Thanks for the suggestion.
Once I got my custom collection configured, the tree really started looking great. But my work came to a screeching halt when I tried to add an unbound CheckBox column, as you suggested. Here is my attempt:
The column shows up, but it appears as an uncheck-able, useless checkbox, in some state that is neither checked nor unchecked. Just looks like a little green square.
So close... but yet so far. Any ideas?