Hi
I have an UltraTree (v12.2).
The ViewStyle is set to OutlookExpress to be able to get all the columns from the different levels properly aligned.
One of the column is a checkbox but I need to display the CheckBox only on rows of the first level (other level can leave the cell empty).
How can I achieve that?
Hi,
I don't think this is possible in OutlookExpress mode, because all of the levels have the same set of display columns. I think you might be able to hide the checkboxes and just show an empty cell on all of the child nodes, but I don't believe it's possible to remove the space.
An empty cell would be fine with me. How can I do it?
If the tree is not bound, then you must be adding each node to the tree in code.
So you could add the node and then set the Editor on the cell immediately after adding the node to the tree.
Another option would be to use a CreationFilter, which is a bit more code, but it might be a bit more efficient and also it will work for both a bound and unbound tree.
private void Form1_Load(object sender, EventArgs e) { this.ultraTree1.CreationFilter = new NodeCheckboxCreationFilter(); }
public class NodeCheckboxCreationFilter : IUIElementCreationFilter { void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // Do nothing. } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { UltraTreeNodeCellUIElement ultraTreeNodeCellUIElement = parent as UltraTreeNodeCellUIElement; if (null != ultraTreeNodeCellUIElement) { UltraTreeNodeCell cell = ultraTreeNodeCellUIElement.GetContext(typeof(UltraTreeNodeCell)) as UltraTreeNodeCell; if (null != cell) { if (cell.Column.Key == "Boolean 1" && cell.Node.Parent != null) { return true; } } } return false; } }
I don't set an editor, I only set the DataType to bool and the CheckBox is correctly displayed. Would it be easier if I would specify an editor?
I will try the CreationFilter on Monday.
Really? If I don't assign a CheckEditor to the column, it displays as "true" or "false" on mine.
Anyway, no - it doesn't matter whether you use an editor or not.
The CreationFilter does the trick. Thanks.
I just checked again and I don't have an editor. Here is my code (referencing v.12.2):
//set the ColumnSet UltraTreeColumnSet rootColumnSet = treeHeaders.ColumnSettings.RootColumnSet; rootColumnSet.AllowCellEdit = AllowCellEdit.Full; _columnSelected = rootColumnSet.Columns.Add("Selected"); _columnSelected.DataType = typeof (bool); _columnSelected.AllowCellEdit = AllowCellEdit.Full; _columnSelected.ButtonDisplayStyle = ButtonDisplayStyle.Always;
Any ideas why I sometimes see some ghost?
As shown on the attached image, only the purple line (level 0) should show a checkbox.
The ghosts appear here and there not always and the same place, sometimes after I do a ExpandAll, sometime when scrolling, ...
It seems that it does the job! Thanks again
Hm, maybe those are leftover checkbox elements that are not getting removed. Right before you return true from the CreationFilter, add this:
parent.ChildElements.Clear();
Let me know if that doesn't help.