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

Programmatically add controls

7 Answers 696 Views
CollapsiblePanel
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 02 Nov 2019, 05:40 PM

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

Sort by
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 02 Nov 2019, 06:18 PM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Nov 2019, 12:59 PM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 04 Nov 2019, 02:55 PM

Thanks a lot for the explanation

Best regards

PJ

0
Martin
Top achievements
Rank 1
answered on 22 Nov 2019, 08:17 AM

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?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Nov 2019, 12:54 PM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Martin
Top achievements
Rank 1
answered on 25 Nov 2019, 07:38 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 25 Nov 2019, 10:51 AM

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

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
CollapsiblePanel
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Martin
Top achievements
Rank 1
Share this question
or