Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
445
UltraTab - Right align last tab
posted

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

 

Parents
  • 445
    posted

    ... 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

    Adrian

      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
      }
    }

Reply Children