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
20
Buttons in Header of Ultra Expandable Group Box Control
posted

Is there a way to add a button to the header of the Ultra Expandable Group Box Control? We would like to have buttons always visible in the headers, preferably right-aligned, on the same level as the header text.

 

Thanks,
Janette

  • 5118
    posted

    Hi Janette,

    In the absence of a property such as ButtonsRight collection on the piece you want to augment you can always use a CreationFilter to add the pieces you want to include.  Make a CreationFilter that adds a ButtonUIElement to the GroupBoxHeaderUIElement and positions itself accordingly. 

    You can read more about CreationFilters here: http://help.infragistics.com/NetAdvantage/WinForms/2011.2/CLR2.0/?page=Win_Creation_Filter.html.

    Some pseudocode to get you started if this is new:

            public void AfterCreateChildElements(Infragistics.Win.UIElement parent)
            {
                if (parent is Infragistics.Win.Misc.GroupBoxHeaderUIElement)
                {
                    Infragistics.Win.Misc.GroupBoxHeaderUIElement header =
                        (Infragistics.Win.Misc.GroupBoxHeaderUIElement) parent;
                    Infragistics.Win.ButtonUIElement button = new ButtonUIElement(parent);
                    Rectangle parentRect = parent.RectInsideBorders;
                    button.Rect = new Rectangle(parentRect.X + parentRect.Width - 20, parentRect.Y, 20, 20);
                    button.Text = "C";
                    button.ElementClick += new UIElementEventHandler(button_ElementClick);
                    parent.ChildElements.Add(button);
                }
            }

            void button_ElementClick(object sender, UIElementEventArgs e)
            {
                MessageBox.Show("Button clicked");
            }

            public bool BeforeCreateChildElements(Infragistics.Win.UIElement parent)
            {
                return false;
            }