Hi
I have an ultratree (ViewStyle = OutlookExpress), can 2 columns show the expansion column?
Hi,
This would be much more complex. I tried out a couple of different ways to get it to work and I couldn't make it work in all cases. The closes I got was this:
public class MyTreeExpansionIndicatorCreationFilter : IUIElementCreationFilter { void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { if (parent is UltraTreeNodeCellUIElement) { int indent = 10; Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement orignalExpansionIndicatorUIElement = null; TreeNodeUIElement nodeElement = parent.GetAncestor(typeof(TreeNodeUIElement)) as TreeNodeUIElement; if (null != nodeElement) { orignalExpansionIndicatorUIElement = nodeElement.GetDescendant(typeof(Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement)) as Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement; if (null != orignalExpansionIndicatorUIElement) indent = orignalExpansionIndicatorUIElement.Rect.X - orignalExpansionIndicatorUIElement.Parent.Rect.X; } UltraTreeNodeColumn column = parent.GetContext(typeof(UltraTreeNodeColumn)) as UltraTreeNodeColumn; if (null != column && column.Key == "String 2") { EditorWithTextUIElement editorWithTextUIElement = parent.GetDescendant(typeof(EditorWithTextUIElement)) as EditorWithTextUIElement; if (null == editorWithTextUIElement) { Debug.Fail("Failed to find EditorWithTextUIElement in the cell; unexpected."); return; } Rectangle parentRect = parent.RectInsideBorders; Rectangle expansionIndicatorUIElementRect = new Rectangle( parentRect.X + indent, parentRect.Y + ((parentRect.Height - 13) / 2), 13, 13); if (null != orignalExpansionIndicatorUIElement) { Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement expansionIndicatorUIElement = parent.GetDescendant(typeof(Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement)) as Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement; if (null == expansionIndicatorUIElement) { expansionIndicatorUIElement = new Infragistics.Win.UltraWinTree.ExpansionIndicatorUIElement(parent); parent.ChildElements.Add(expansionIndicatorUIElement); } expansionIndicatorUIElement.Rect = expansionIndicatorUIElementRect; } editorWithTextUIElement.Rect = new Rectangle( expansionIndicatorUIElementRect.Right, editorWithTextUIElement.Rect.Y, editorWithTextUIElement.Rect.Width, editorWithTextUIElement.Rect.Height); } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // do nothing return false; } }
Basically, what this does is it tries to get the original expansion indicator from the real NodeTextColumn. If it doesn't find one, it doesn't show the expansion indicator in the second column, either. If it does find one, it uses it to determine the indent.
The problem with this approach is that it relies on the UIElements. So if you scroll the real NodeTextColumn out of view, the expansion indicator goes away.So this approach will work as long as your tree doesn't allow scrolling.
and is there an easy way to not display the expansion indicator when no children like:
treeHeadersLeft.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnDisplay;
I found a way to indent:
Rectangle expansionIndicatorUIElementRect = new Rectangle(parentRect.X + (((UltraTreeNodeCellUIElement)parent).Node.Level * 20), parentRect.Y + ((parentRect.Height - 13) / 2), 13, 13);
How can I get the indent width (to put instead of my 20 constant)
Almost.
Why isn't the expansion indicators indented?
I found a way to do it without triggering the bug, so just ignore my previous response.
I am attaching a small sample project that adds the expansion indicators into a second column using a CreationFilter.