This is a migrated thread and some comments may be shown as answers.

RadGroupBox, add button to GroupHeader

3 Answers 158 Views
GroupBox
This is a migrated thread and some comments may be shown as answers.
GunGar
Top achievements
Rank 1
GunGar asked on 12 Oct 2009, 08:22 PM
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 );
    }
}

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 13 Oct 2009, 07:53 AM
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.
0
GunGar
Top achievements
Rank 1
answered on 13 Oct 2009, 12:22 PM
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
0
Nick
Telerik team
answered on 15 Oct 2009, 10:03 AM
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.
Tags
GroupBox
Asked by
GunGar
Top achievements
Rank 1
Answers by
Nick
Telerik team
GunGar
Top achievements
Rank 1
Share this question
or