Hi
I have an ultratree (ViewStyle = OutlookExpress), can 2 columns show the expansion column?
Hi,
There's no built-in way to do this, but it might be possible using a CreationFilter to insert an expansion indicator into another cell. It depends on the contents of the cell and what kind of editor it's using, though.
Which two cells do you want the indicator to show up in? Are they both strings? Are they editable?
I am trying to build a UI similar to Beyond Compare when comparing 2 folders. It looks like you have a tree on the left and a second one on the right.
I am trying to have a UI similar to this with a single ultratree control.
I currently have set ViewStyle to OutlookExpress so I have my columns but would like to display the expansion in a second column.
Both columns are strings. So far, I don't need to have them editable.
Almost.
Why isn't the expansion indicators indented?
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)
and is there an easy way to not display the expansion indicator when no children like:
treeHeadersLeft.Override.ShowExpansionIndicator = ShowExpansionIndicator.CheckOnDisplay;
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.
With your new code, with the Show set to ShowExpansionIndicator.CheckOnDisplay, the nodes without the indicator appears completely left aligned.
Thanks. It looks a lot better now.
Ooooh, I see the problem, now. The references have nothing to do with it, I just misunderstood the problem. I thought you were talking about the indentation of the expansion indicators, but you meant the child rows. I misread it, sorry. I didn't even notice that part, so there was nothing in my sample to handle it.
Here's a new sample that works a lot better.
It is not working for me but I think I partly found why.
When I open your test solution (in VS2012), 2 references are wrong (as shown in 86212-references.png).
So I remove the reference to UIElementViewer as it doesn't seem to be required.
I replace the reference to the UltraWinTree with my local (also v12.2).
I run the solution and the children nodes are left aligned (as shown in 86212-rendering.png).
The issue might be that there are 2 versions on v12.2 as shown in 86212-references-code.png)! My version is 12.2.20122.2027 and yours seems to be 12.2.0.9000. Can it be the issue? Any fix for my (sub-)version?
I tried this out, and it seems to work okay for me. I have attached an updated sample using CheckOnDisplay.