Hello I can't find how to programmatically add controls into a RadCollapsibleControl
From the documentation I thought I should add to the
CollapsiblePanelLayoutElement
But I do not find access to this element.
Thanks in advance
Pierre-Jean
7 Answers, 1 is accepted
Well I realized that my control was added but not visible (it seems it was behind the container)
so It works with:
radcollapsiblepanel1.panelcontainer.controls.add(mycontrol)
Thanks
Hello, Pierre-Jean,
The CollapsiblePanelLayoutElement is the container that holds the added controls. Please refer to the elements structure of RadCollapsiblePanel for further information: https://docs.telerik.com/devtools/winforms/controls/panels-and-labels/collapsiblepanel/structure
If you create a brand new project and drag a RadButton from the toolbox and drop it inside RadCollapsiblePanel, you will notice in the InitializeComponent that it is added to the RadCollapsiblePanel.PanelContainer.Controls collection:
this.radCollapsiblePanel1.PanelContainer.Controls.Add(this.radButton1);
This is the appropriate way to add controls programmatically to RadCollapsblePanel.
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Thanks a lot for the explanation
Best regards
PJ
I add controls (Buttons) to the header with
panel.CollapsiblePanelElement.HeaderElement.Children.Insert(x, buttonElement);
but these buttons are stretched to the width of the header. I have to set AutoSize = false and to set the Size.
But the main-problem is the location of the buttons. When i add 3 Buttons the second is in the middle and the third is on the right.
The HeaderElement is HorizontalHeaderAlignment=left and StretchHorizontally=true.
When i change the StretchHorizontally to false the header Element is in the middle of the CollapsiblePanel.
Why the buttons are not left next to each other instead of distributed of the hole area?
Hello, Martin,
Please refer to the below code snippet demonstrating how to add 3 RadButtonElements next to each other as it is illustrated in the below screenshot:
RadButtonElement btn1 = new RadButtonElement();
btn1.Text = "A";
btn1.AutoSize = false;
btn1.Size = btn1.MinSize = btn1.MaxSize = new System.Drawing.Size(30, 20);
btn1.StretchHorizontally = false;
RadButtonElement btn2= new RadButtonElement();
btn2.Text = "B";
btn2.Size = btn2.MinSize = btn2.MaxSize = new System.Drawing.Size(30, 20);
btn2.StretchHorizontally = false;
RadButtonElement btn3 = new RadButtonElement();
btn3.Text = "C";
btn3.Size = btn3.MinSize = btn3.MaxSize = new System.Drawing.Size(30, 20);
btn3.StretchHorizontally = false;
this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Children.Insert(1, btn1);
this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Children.Insert(2, btn2);
this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Children.Insert(3, btn3);
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Good Morning,
i think to not stretch the elemtents (with "StretchHorizontally = false) is the missing information i searched for! :-)
I´m a web developer and don´t expect such configuration, i have to learn develop for desktop applications. ;-)
Best regards
Hello, Martin,
I am glad that the provided solution was helpful for you to discover what was missing on your end.Indeed, the web development is not expected to be the same as the desktop development. I would recommend you to have a look at the following Getting Started section in MSDN which is a good tutorial to get you familiar with the specifics of the Windows Forms technology: https://docs.microsoft.com/en-us/dotnet/framework/winforms/getting-started-with-windows-forms
Should you have further questions please let me know.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik