Search
Accordion Class
Remarks See Also
 





A container control that displays a stack of collapsible panes.

Namespace: MindFusion.Common.WinForms
Assembly: MindFusion.Common.WinForms

 Syntax

C#  Copy Code

public class Accordion : FlowLayoutPanel

Visual Basic  Copy Code

Public Class Accordion
    Inherits FlowLayoutPanel

 Remarks

The Accordion control organizes its child panels vertically and provides a flexible space-distribution model tailored for sidebars, toolbox panels, and palettes.

Pane Management

Accordion inherits directly from System.Windows.Forms.FlowLayoutPanel. Consequently, child panels are managed using standard WinForms collection patterns. You can add panels programmatically by instantiating an AccordionItem and calling Controls.Add on the parent Accordion. Individual panes are removed using Controls.Remove, and the entire container can be cleared using Controls.Clear.

C#  Copy Code

var item = new AccordionItem { Title = "Utilities", Icon = myFolderIcon };
item.ContentPanel.Controls.Add(new MyUtilityControl());
accordion.Controls.Add(item);

Layout and Sizing

Only expanded panes are allowed to stretch and display their content area. Collapsed panes automatically hide their content panels and shrink to show only their header panels.

Because Accordion is a vertical, non-wrapping FlowLayoutPanel, all items naturally align and stack tightly at the top of the container. If all panes are collapsed, they will cluster at the top of the viewport, leaving any remaining empty space at the bottom of the container.

The AccordionItem supports two sizing modes for its content:

  • Explicit Sizing: Setting the ContentHeight property to a non-null pixel value explicitly constrains the content height.
  • Dynamic Sizing (Default): If ContentHeight is null, the AccordionItem queries the standard GetPreferredSize method of the first child control hosted in its ContentPanel to automatically measure and fit the control's ideal size. If the hosted control’s size changes dynamically, you can call the UpdateContentSize method on the AccordionItem to force a layout recalculation.

Expansion Management

By default, the Accordion allows multiple panes to be expanded concurrently. Setting the AllowMultipleExpands property to false enables single-expand mode, where expanding one pane automatically collapses all other panes in the control.

The expansion state of an individual pane can be programmatically queried or updated using the IsExpanded property on the AccordionItem. Any change to this state raises the IsExpandedChanged event, allowing listeners to react to visibility changes.

 Inheritance Hierarchy

System.Object
    System.MarshalByRefObject
        System.ComponentModel.Component
            System.Windows.Forms.Control
                System.Windows.Forms.ScrollableControl
                    System.Windows.Forms.Panel
                        System.Windows.Forms.FlowLayoutPanel
                            MindFusion.Common.WinForms.Accordion

 See Also