Hi
I'm working on an UltraTab with 3 tabs. TabLayoutStyle is SingleRowAutoSize (default) and TabOrientation is also default.
With these settings all three tabs are left aligned as expected. However, I'd really like the first two left aligned but the third and final one right aligned. Is it possible to do this?
Regards
Adrian
... to follow on from the original question, I put together a creation filter (code snippet below) which seems to work in my scenario. It simply sets the rect.X co-ord for the final tab.
I make several assumptions (such as TabLayoutStyle = SingleRowAutoSize and TabOrientation = TopLeft) and the code is fairly crude but do you think this is a reasonable approach? I would have liked to get a handle on a UIElement alignment/orientation property which might have been neater.
Advice greatly appreciated.
Thanks
public class RightTabAlignCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members public void AfterCreateChildElements(UIElement parent) { if (parent is Infragistics.Win.UltraWinTabs.TabRowUIElement) { foreach (Infragistics.Win.UIElement thisElem in parent.ChildElements) { if (thisElem is Infragistics.Win.UltraWinTabs.TabItemUIElement) { Infragistics.Win.UltraWinTabs.TabItemUIElement tabItem = (Infragistics.Win.UltraWinTabs.TabItemUIElement)thisElem; Infragistics.Win.UltraWinTabControl.UltraTabControl tabControl = (Infragistics.Win.UltraWinTabControl.UltraTabControl)tabItem.Control; if (tabItem.TabItem.Index == tabControl.Tabs.Count - 1) { int newXPos = tabControl.Width - tabItem.Rect.Width; if (newXPos > tabItem.Rect.X) { tabItem.Rect = new Rectangle(newXPos, tabItem.Rect.Y, tabItem.Rect.Width, tabItem.Rect.Height); } } } } } } public bool BeforeCreateChildElements(UIElement parent) { return false; } #endregion }}
Hello,
I would use a little different AfterCreateChildElements method in your CraetionFilter, to achieve what you are looking for. Please take a look at the code snippet below:
public void AfterCreateChildElements(UIElement parent) { TabRowUIElement tabRow; TabItemUIElement tabItem;
tabItem = parent as TabItemUIElement; if (tabItem != null) { if (tabItem.TabItem.Index == ((UltraTabControl)tabItem.Control).Tabs.Count - 1) { tabRow = (TabRowUIElement)tabItem.Parent; tabItem.Rect = new Rectangle((tabRow.Rect.X + tabRow.Rect.Width - tabItem.Rect.Width), tabItem.Rect.Y, tabItem.Rect.Width, tabItem.Rect.Height); } } }
Please let me know if you have any other questions.
Hello Adrian,
I am glad that I was able to help you.
Please let us know if you need any other assistance.
That's great and much more concise than my attempt.
Before setting the new X position is still test that it's greater than the original value to stop the tab 'sliding' behind other tabs if the user resizes the control:
int newXPos = tabRow.Rect.X + tabRow.Rect.Width - tabItem.Rect.Width; if (newXPos > tabItem.Rect.X) { tabItem.Rect = new Rectangle(newXPos, tabItem.Rect.Y, tabItem.Rect.Width, tabItem.Rect.Height); }
Thanks very much Danko.