Back to Devexpress

SplitterControl Class

windowsforms-devexpress-dot-xtraeditors-d19465b3.md

latest5.7 KB
Original Source

SplitterControl Class

Allows a user to resize controls docked to the splitter’s edges.

Namespace : DevExpress.XtraEditors

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public class SplitterControl :
    Splitter,
    ISupportLookAndFeel,
    IXtraSerializable,
    IXtraSerializable2,
    ISupportAppearanceObjectPropertiesFilter
vb
Public Class SplitterControl
    Inherits Splitter
    Implements ISupportLookAndFeel,
               IXtraSerializable,
               IXtraSerializable2,
               ISupportAppearanceObjectPropertiesFilter

Remarks

The SplitterControl functions as the Splitter class. A splitter can be placed between two controls to resize the areas occupied by these controls.

The SplitterControl also supports the look and feel mechanism and appearances (accessible through SplitterControl.LookAndFeel and SplitterControl.Appearance properties).

The area to the left or right of the splitter cannot exceed the resized control’s maximum width. To specify a minimum allowed area width, set the splitter’s MinSize and MinExtra properties.

Tip

As an alternative, you can use the SplitContainerControl class. It consists of two panels separated by a splitter.

Add a Vertical Splitter

At Design Time

  1. Drop the left control on the form and set the control’s Dock property to DockStyle.Left.
  2. Drop a SplitterControl on the form and set the splitter’s Dock property to DockStyle.Left.
  3. Drop the right control on the form and set the control’s Dock property to DockStyle.Fill.

In Code

The following code snippet creates a layout with two controls divided by a vertical SplitterControl.

csharp
using DevExpress.XtraBars.Navigation;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid;

namespace splitter {
    public partial class Form1 : XtraForm {
        GridControl grid;
        SplitterControl splitter;
        AccordionControl accordion;
        public Form1() {
            InitializeComponent();
            // Create an Accordion and dock it to the left
            accordion = new AccordionControl();
            accordion.Dock = DockStyle.Left;
            var salesItem = accordion.AddItem();
            salesItem.Text = "Sales";
            // Create a Splitter and also dock it to the left
            splitter = new SplitterControl();
            splitter.Dock = DockStyle.Left;
            // Create a Grid and dock it to fill the remaining space
            grid = new GridControl();
            grid.Dock = DockStyle.Fill;
            // Add controls to the form in inverted order (from right to left)
            this.Controls.AddRange(new Control[] { grid, splitter, accordion });
        }
    }
}
vb
Imports DevExpress.XtraBars.Navigation
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid

Namespace splitter
    Public Partial Class Form1
        Inherits XtraForm
        Private grid As GridControl
        Private splitter As SplitterControl
        Private accordion As AccordionControl

        Public Sub New()
            InitializeComponent()
            ' Create an Accordion and dock it to the left
            accordion = New AccordionControl()
            accordion.Dock = DockStyle.Left
            Dim salesItem = accordion.AddItem()
            salesItem.Text = "Sales"
            ' Create a Splitter and also dock it to the left
            splitter = New SplitterControl()
            splitter.Dock = DockStyle.Left
            ' Create a Grid and dock it to fill the remaining space
            grid = New GridControl()
            grid.Dock = DockStyle.Fill
            ' Add controls to the form in inverted order (from right to left)
            Me.Controls.AddRange(New Control() {grid, splitter, accordion})
        End Sub
    End Class
End Namespace

Inheritance

Object MarshalByRefObject Component Control Splitter SplitterControl

See Also

SplitContainerControl

SplitterControl Members

DevExpress.XtraEditors Namespace