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
1110
UltraOptionSet item positioning
posted

Is it possible to position the items in an UltraOptionSet individually?

Parents Reply
  • 469350
    Offline posted in reply to Erik Peschier

    Okay, that should be pretty easy to do with a CreationFilter.

    If you want to try it out, I recommend get the Infragistics UIElementViewer Utility.

    This utility is a huge help when working with CreationFilters because it allows you to see the UIElement hierarchy of the control.

    Basically, you just need to find the UIElement that contains the options and trap the AfterCreateChildElements for that phase. Then you can re-position the child elements wherever you want with the parent by setting the Rect.

    Here's some quick sample code I threw together:

    this.ultraOptionSet1.CreationFilter = new MyOptionSetCreationFilter();

    public class MyOptionSetCreationFilter : IUIElementCreationFilter
        {
            #region IUIElementCreationFilter Members

            public void AfterCreateChildElements(UIElement parent)
            {
                if (parent is OptionSetEmbeddableUIElement)
                {
                    foreach (UIElement element in parent.ChildElements)
                    {
                        ValueListItem item = element.GetContext(typeof(ValueListItem)) as ValueListItem;
                        switch (item.DataValue.ToString())
                        {
                            case "ValueListItem0":
                                element.Rect = new Rectangle(0, 0, element.Rect.Width, element.Rect.Height);
                                break;
                            case "ValueListItem1":
                                element.Rect = new Rectangle(20, 50, element.Rect.Width, element.Rect.Height);
                                break;
                            case "ValueListItem2":
                                element.Rect = new Rectangle(15, 70, element.Rect.Width, element.Rect.Height);
                                break;
                        }
                    }
                }
            }

            public bool BeforeCreateChildElements(UIElement parent)
            {
                // Do nothing
                return false;
            }

            #endregion
        }

     

    I have also attached a sample project with the same code.

     

    WindowsFormsApplication35.zip
Children
No Data