RadGroupBox, add button to GroupHeader

4 posts, 0 answers
  1. GunGar
    GunGar avatar
    2 posts
    Member since:
    Sep 2009

    Posted 12 Oct 2009 Link to this post

    I would like to add a button, maybe two, to the GroupHeader of a RadGroupBox, I've tried the following, however the button is not the correct size, it looks like it's being rendered at one pixel wide:

    public class TestGroupBox : RadGroupBox
    {
        private StackLayoutPanel  m_objStackLayoutPanel  = new StackLayoutPanel ();
        private RadButtonElement m_objButton = new RadButtonElement();

        protected override void CreateChildItems( RadElement parent )
        {
            base.CreateChildItems( parent );

            m_objStackLayoutPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;

            ImageAndTextLayoutPanel panel = this.GroupBoxElement.Header.Children[2] as ImageAndTextLayoutPanel;
            this.GroupBoxElement.Header.Children.RemoveAt( 2 );
            this.GroupBoxElement.Header.Children.Add( m_objStackLayoutPanel );

            m_objStackLayoutPanel.Children.Add( m_objButton );
            m_objButton.Size = new System.Drawing.Size( 16, 16 );
            m_objStackLayoutPanel.Children.Add( panel );
        }
    }

  2. Nick
    Admin
    Nick avatar
    767 posts

    Posted 13 Oct 2009 Link to this post

    Hi Scott,

    Thank you for contacting us. Well, this scenario was not really considered when RadGroupBox control was written. Nevertheless, you can try this approach:

    RadButtonElement button = new RadButtonElement();
    button.MinSize = new Size(30, 30);
    this.radGroupBox1.GroupBoxElement.Header.MinSize = new Size(70, 50);
    this.radGroupBox1.GroupBoxElement.Header.Children.Add(button);

    You can place this code in your form load event handler.

    Greetings,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. GunGar
    GunGar avatar
    2 posts
    Member since:
    Sep 2009

    Posted 13 Oct 2009 Link to this post

    Thanks for this tip, I'll try it out.

    The reason I want a button in the GroupHeader, is that the control already allows an Image, but I need that image to be clickable, and at times add two images.

    Thanks,
    Scott
  5. Nick
    Admin
    Nick avatar
    767 posts

    Posted 15 Oct 2009 Link to this post

    Hi Scott,

    I see. Do not hesitate to write back if you have more questions. 

    Best wishes,
    Nick
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top