Siticone Logo
Siticone UI
DOCS
v2025.12.15
Docs Split Container

Siticone Split Container

The SiticoneSplitContainer is a powerful enhancement over the standard WinForms SplitContainer. It introduces modern features such as animated resizing, snapping, layout persistence (JSON), and extensive accessibility support, making it ideal for creating professional IDE-like layouts or complex dashboards.

Behavior & Snapping

Controls how the splitter reacts to user input, including magnetic snapping to specific ratios.

Property Type Description & Usage Example
EnableSnapping bool splitContainer.EnableSnapping = true; When enabled, the splitter magnetically snaps to positions defined in SnapPositions.
SnapPositions float[] splitContainer.SnapPositions = new float[] { 0.25f, 0.5f, 0.75f }; Array of normalized values (0.0 to 1.0) representing snap points relative to the total size.
SnapDistance int splitContainer.SnapDistance = 20; The distance in pixels the mouse must be to a snap point to trigger snapping.
EnableAutoHide bool splitContainer.EnableAutoHide = true; If enabled, the splitter automatically collapses to 0 after the AutoHideDelay passes without interaction.
IsSplitterLocked bool splitContainer.IsSplitterLocked = true; Freezes the splitter in place, preventing mouse or keyboard resizing.

Animation & Transitions

Configuration for smooth visual transitions when resizing panels programmatically or via drag.

Property Type Description & Usage Example
EnableSmoothDrag bool splitContainer.EnableSmoothDrag = true; Enables frame-rate limited repainting during drag operations to reduce flickering.
EnableAnimatedSplitter bool splitContainer.EnableAnimatedSplitter = true; Enables animation when the splitter position changes programmatically (e.g., via hotkey).
AnimationInterval int splitContainer.AnimationInterval = 15; The time in milliseconds between animation frames.
AnimationStep int splitContainer.AnimationStep = 10; The number of pixels the splitter moves per animation frame.

Appearance & Layout

Customize the visual look of the splitter bar and panels.

Property Type Description & Usage Example
EnableSplitterHighlight bool splitContainer.EnableSplitterHighlight = true;
SplitterHighlightColor Color splitContainer.SplitterHighlightColor = Color.DodgerBlue; The color the splitter turns when hovered over.
ShowPanelHeaders bool splitContainer.ShowPanelHeaders = true; Displays customizable title headers at the top of Panel1 and Panel2.
Panel1Title string splitContainer.Panel1Title = "Solution Explorer";
SplitterTexture Image splitContainer.SplitterTexture = Resources.GripTexture; Draws a custom image or grip texture on the splitter bar.

State Management (JSON)

Built-in capability to save and restore the layout state using JSON format.

ExportLayout()
// Serializes the current layout configuration to a JSON string.
// Includes SplitterDistance, Orientation, Collapsed state, etc.
string jsonConfig = siticoneSplitContainer1.ExportLayout();
File.WriteAllText("layout.json", jsonConfig);
ImportLayout(string json)
// Restores the layout from a JSON string.
if (File.Exists("layout.json"))
{
                string json = File.ReadAllText("layout.json");
    siticoneSplitContainer1.ImportLayout(json);
}

Accessibility & Hotkeys

Enhanced keyboard support for power users and accessibility compliance.

Property Type Description & Usage Example
EnableKeyboardNavigation bool splitContainer.EnableKeyboardNavigation = true; Allows moving the splitter using arrow keys when focused.
EnableHotkeys bool splitContainer.EnableHotkeys = true;
SwapPanelsHotkey Keys splitContainer.SwapPanelsHotkey = Keys.Control | Keys.Alt | Keys.S; Global hotkey to swap contents of Panel1 and Panel2.
ToggleOrientationHotkey Keys splitContainer.ToggleOrientationHotkey = Keys.Control | Keys.Alt | Keys.O; Hotkey to switch between Vertical and Horizontal orientation.

Events

Comprehensive event hooks for custom logic.

Event Description
SplitterSnapping Fired just before the splitter snaps to a SnapPositions value.
SplitterBoundsReached Fired when the splitter hits the minimum or maximum allowed position (Panel1MinSize/Panel2MinSize).
PanelVisibilityChanged Fired when a panel is programmatically collapsed or expanded.
PanelsSwapped Fired after SwapPanels() is executed successfully.
OrientationChanged Fired after the orientation is toggled between Horizontal and Vertical.

Detailed Usage Examples

Example 1: IDE Layout with Snapping

Configures a layout similar to Visual Studio, where the bottom output panel snaps to 25%, 50%, or 75% height.

C# - IDE Layout Setup
private void SetupIDELayout()
{
    splitContainer1.Orientation = Orientation.Horizontal;
    
                // Enable snapping to quarters
    splitContainer1.EnableSnapping = true;
    splitContainer1.SnapPositions = new float[] { 0.25f, 0.5f, 0.75f };
    splitContainer1.SnapDistance = 15; // Snaps when within 15px
    
                // Visual Feedback
    splitContainer1.EnableSplitterHighlight = true;
    splitContainer1.SplitterHighlightColor = Color.Orange;
    
                // Panel Headers
    splitContainer1.ShowPanelHeaders = true;
    splitContainer1.Panel1Title = "Code Editor";
    splitContainer1.Panel2Title = "Output Window";
}

Example 2: Collapsible Sidebar

Demonstrates how to create a sidebar that can be toggled open/closed with smooth animation.

C# - Animated Sidebar
private void btnToggleSidebar_Click(object sender, EventArgs e)
{
                // Ensure animation is enabled for smooth transition
    splitContainer1.EnableAnimatedSplitter = true;
    splitContainer1.AnimationStep = 20; // Speed of animation

                // Check if Panel1 (Sidebar) is currently collapsed
                if (splitContainer1.IsPanel1Collapsed)
    {
                // Restore to default width (e.g., 250px)
                // Note: Setting SplitterDistance triggers the animation automatically
        splitContainer1.SplitterDistance = 250;
    }
                else
    {
                // Collapse Panel1
        splitContainer1.SplitterDistance = splitContainer1.Panel1MinSize;
    }
}

Example 3: Secure/Locked Mode

Useful for "Kiosk Mode" or fixed layouts where the user should not resize panels. It disables the cursor and locks the splitter.

C# - Layout Lock
private void SetLayoutLock(bool isLocked)
{
    splitContainer1.IsSplitterLocked = isLocked;
    
                if (isLocked)
    {
                // Visual indication that it is locked
        splitContainer1.Cursor = Cursors.Default;
        lblStatus.Text = "Layout Locked";
    }
                else
    {
                // Restore splitter cursor
        splitContainer1.Cursor = Cursors.VSplit;
        lblStatus.Text = "Layout Editable";
    }
}

Example 4: State Persistence with Registry

Automatically saves the splitter position when the form closes and restores it when opened.

C# - State Management
public MainForm()
{
                InitializeComponent();
    
                // 1. Enable State Management
    siticoneSplitContainer1.EnableStateManagement = true;
    
                // 2. Define a unique key for Registry storage
    siticoneSplitContainer1.SplitterPositionKey = "MyApp_MainSplitter";
}

// The control automatically handles Load/Save logic during 
// Parent.HandleCreated and Parent.HandleDestroyed events.
// No manual Load/Save code required in Form_Load/Form_Closing.