add a button to the header element of a radcollapsible panel

3 Answers 201 Views
Buttons, RadioButton, CheckBox, etc CollapsiblePanel
mansouri
Top achievements
Rank 1
Iron
mansouri asked on 16 May 2022, 02:31 PM

is it posssible to add a button to the header of a radcollapsiblepanel from the designer code ,if so can a anyone please guide me. 

 

3 Answers, 1 is accepted

Sort by
0
Accepted
mansouri
Top achievements
Rank 1
Iron
answered on 17 May 2022, 08:19 AM | edited on 17 May 2022, 09:15 AM

so after a lot of search i've managed to add the button to the header by creating a button element and adding that button to children items of the  collapsible panel header :

RadButtonElement buttonElement = new RadButtonElement()
            {
                Text = "Custom Button",
            };

this.YourCollapsiblepanelName.CollapsiblePanelElement.HeaderElement.Children.Insert(1, buttonElement);

but theres is an issue with sizing when the button size is set to true it fills the  header size 

 

and when i give it a specfic size it creates a button with that size but makes a margin (red line)to fill the header width so haw can i remove this margin and make the header line takes all the rest space  

 

 

Dinko | Tech Support Engineer
Telerik team
commented on 17 May 2022, 09:17 AM

Thank you for sharing your solution. You are on the right track. Using the Children collection of the HeaderElement you can add additional elements (buttons in your case).
mansouri
Top achievements
Rank 1
Iron
commented on 17 May 2022, 09:20 AM | edited

can you help me with fixing the sizing issue i can't figure out what elemnt to edit in the buttonelement to not make it create that margin or padding 
0
mansouri
Top achievements
Rank 1
Iron
answered on 17 May 2022, 10:17 AM | edited on 23 May 2022, 10:39 AM

answered by dess

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 19 May 2022, 10:31 AM
Hello, Mansouri,   

My colleague, Dinko, is out of office today so I will be assisting you with this case. Make sure that the button element is not stretched horizontally. I have prepared a sample code snippet for your reference which result is illustrated below:
        public RadForm1()
        {
            InitializeComponent();
            RadButtonElement buttonElement = new RadButtonElement()
            {
                Text = "Custom Button",
                MinSize= new Size(100,20),
                MaxSize = new Size(100,20),
                StretchHorizontally = false
            };

            this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Children.Insert(1, buttonElement);
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

mansouri
Top achievements
Rank 1
Iron
commented on 20 May 2022, 11:04 AM

thanks that is way better solution .
Tags
Buttons, RadioButton, CheckBox, etc CollapsiblePanel
Asked by
mansouri
Top achievements
Rank 1
Iron
Answers by
mansouri
Top achievements
Rank 1
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or