I have a tree in Grid view, bound to a list (which is a custom type derived from BindingList) of objects (which implement INotifyPropertyChanged). One of the columns is of type CheckState (set in code, since the Designer doesn't know about that type), and is bound to an object property which is declared as CheckState. All of these properties default to unchecked.
Here's the behavior: if I check the checkbox on one item, nothing happens (that is, the property on the object does not get set). If I now check the checkbox on a second item, the property on the *first* item is set, but not the property on the second item. If I check a third item, the second item will get set, and so forth. When the property is modified, I am firing the PropertyNotified event like I'm supposed to.
This is pretty clearly something wrong with my code. Any idea what I could be doing to cause this behavior?
Thanks, Aaron
OK, I reread your previous post. You're correct, if I had a Customer at each level of the tree and a Customer could have a list of sub-Customers, that would probably solve the problem. Unfortunately, I don't want a customer at each level; the collections have their own fields (represented by Index in this example) that I need to display.
So, I've created a base class named TreeNodeOb that implements INotifyPropertyChanged and provides a BindingList<TreeNodeOb> as one of its properties, and derived both Customer and CustomerCollection from that class. Now, I have more or less what you suggested - a data structure with an object at each level that provides property-changed notifications. I now need to bind the tree to the Children property of my base-level object, but that's OK.
So, that's good progress, thank you. That just leaves my secondary question: is there any way to support recursive updates from the higher-level checkboxes? That is, if I check a group, I want to check all the items contained within that group. Unfortunately, since the update doesn't occur until I leave the cell, I have no way to make that happen immediately. Is there any way to force the update to occur immediately? Can I detect the click in the checkbox somehow and force a refresh?
Hi Aaron,
There's no event for this directly on the tree control. But you could hook the ValueChanged event of the column's editor.
private void Form1_Load(object sender, EventArgs e) { this.ultraTree1.SetDataBinding(this.ultraDataSource1, "Band 0"); this.ultraTree1.ColumnSettings.AllowCellEdit = Infragistics.Win.UltraWinTree.AllowCellEdit.Full; this.ultraTree1.Override.CellClickAction = Infragistics.Win.UltraWinTree.CellClickAction.EditCell; this.ultraTree1.ColumnSettings.ColumnSets[0].Columns["Column 0"].EditorResolved.ValueChanged += new EventHandler(EditorResolved_ValueChanged); } void EditorResolved_ValueChanged(object sender, EventArgs e) { EmbeddableEditorBase editor = (EmbeddableEditorBase)sender; UIElement elementBeingEdited = editor.ElementBeingEdited; if (elementBeingEdited == null) return; UltraTreeNodeCell cell = editor.ElementBeingEdited.GetContext(typeof(UltraTreeNodeCell)) as UltraTreeNodeCell; Debug.WriteLine("Node " + cell.Node.Index.ToString() + " checkbox set to " + editor.Value.ToString()); }