Collapsible Panel - Hidden Panel - Programmatically Control if it is expanded or not.

1 Answer 14 Views
CollapsiblePanel
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
Mark asked on 04 Sep 2025, 08:16 PM

I want to control a collapsible panel programmatically.  Also, I want the button section at the top hidden.  So far, I have that part working.  I also have the expanding/collasping working as well, but I have run into a problem. When I collapse the panel, the panel does not collapse all the way, it still sticks out a little bit, by like 12-14 pixels (in this case, on the bottom).  This is a problem for me, as I am expecting that entire space to be gone.

 

This is the Collasible Panel, where I have hidded the Header Panel and IsExanded is set to false:

 

This is the designer.cs part.  I am not sure what I am missing. What else to I need to do to make the panel have a height of 0.

namespace TEST
{
   partial class RadForm1
   {
      /// <summary>
      /// Required designer variable.
      /// </summary>
      private System.ComponentModel.IContainer components = null;
 
      /// <summary>
      /// Clean up any resources being used.
      /// </summary>
      /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
      protected override void Dispose(bool disposing)
      {
         if (disposing && (components != null))
         {
            components.Dispose();
         }
         base.Dispose(disposing);
      }
 
      #region Windows Form Designer generated code
 
      /// <summary>
      /// Required method for Designer support - do not modify
      /// the contents of this method with the code editor.
      /// </summary>
      private void InitializeComponent()
      {
         this.radCollapsiblePanel1 = new Telerik.WinControls.UI.RadCollapsiblePanel();
         ((System.ComponentModel.ISupportInitialize)(this.radCollapsiblePanel1)).BeginInit();
         this.radCollapsiblePanel1.SuspendLayout();
         ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
         this.SuspendLayout();
         // 
         // radCollapsiblePanel1
         // 
         this.radCollapsiblePanel1.IsExpanded = false;
         this.radCollapsiblePanel1.Location = new System.Drawing.Point(8496);
         this.radCollapsiblePanel1.Name = "radCollapsiblePanel1";
         this.radCollapsiblePanel1.OwnerBoundsCache = new System.Drawing.Rectangle(8496393200);
         // 
         // radCollapsiblePanel1.PanelContainer
         // 
         this.radCollapsiblePanel1.PanelContainer.Size = new System.Drawing.Size(00);
         this.radCollapsiblePanel1.Size = new System.Drawing.Size(39321);
         this.radCollapsiblePanel1.TabIndex = 1;
         ((Telerik.WinControls.UI.RadCollapsiblePanelElement)(this.radCollapsiblePanel1.GetChildAt(0))).IsExpanded = false;
         ((Telerik.WinControls.UI.CollapsiblePanelHeaderElement)(this.radCollapsiblePanel1.GetChildAt(0).GetChildAt(1))).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
         // 
         // RadForm1
         // 
         this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
         this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
         this.ClientSize = new System.Drawing.Size(511254);
         this.Controls.Add(this.radCollapsiblePanel1);
         this.Name = "RadForm1";
         this.Text = " ";
         ((System.ComponentModel.ISupportInitialize)(this.radCollapsiblePanel1)).EndInit();
         this.radCollapsiblePanel1.ResumeLayout(false);
         ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
         this.ResumeLayout(false);
 
      }
 
      #endregion
 
      private Telerik.WinControls.UI.RadCollapsiblePanel radCollapsiblePanel1;
   }
}

 

 

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 08 Sep 2025, 01:00 PM

Hi Mark,

Thank you for sending me the code snippet and screenshot. Looking at the code fragment, it seems that you have accessed the header element inside the Visual Studio designer to set its Visilibity. I tested it in a sample project and on my end I am not seeing the bottom part sticking out a little bit. Here is the result when running you form: 

Can you please check if you are running the app on a system with an increased scaling. If that is the case you can try declearing your application to be DPI-aware, this way it will scale according to the Windows settings. Another thing that you can try is to collapse the Header at runtime and not inside the designer. Please comment the following code inside the designer file:

//((Telerik.WinControls.UI.RadCollapsiblePanelElement)radCollapsiblePanel1.GetChildAt(0)).IsExpanded = false;
//((Telerik.WinControls.UI.CollapsiblePanelHeaderElement)radCollapsiblePanel1.GetChildAt(0).GetChildAt(1)).Visibility = Telerik.WinControls.ElementVisibility.Collapsed;

Then you collapse the header inside your form's constructor right after the InitializeComponent method call:

 this.radCollapsiblePanel1.CollapsiblePanelElement.HeaderElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;

I hope this will help. Let me know if you need further assistance.

Regards,
Hristo
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
CollapsiblePanel
Asked by
Mark
Top achievements
Rank 2
Bronze
Bronze
Veteran
Answers by
Hristo
Telerik team
Share this question
or