This documentation is archived and is not being maintained.

SplitContainer.OnSplitterMoved Method

Raises the SplitterMoved event.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public void OnSplitterMoved(
	SplitterEventArgs e


Type: System.Windows.Forms.SplitterEventArgs
A SplitterEventArgs that contains the event data.

The SplitterMoved event is raised after the splitter has been moved. When the SplitContainer is in the process of moving, use the SplitterMoving event and the OnSplitterMoving event handler.

Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

The OnSplitterMoved method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

Notes to Inheritors

When overriding OnSplitterMoved in a derived class, be sure to call the base class's OnSplitterMoved method so that registered delegates receive the event.

The following code example raises the SplitterMoving event, signified in this example by a change to the cursor style when you move the splitter. The SplitterMoved event is raised when you stop moving the splitter. This is signified in this example by the cursor style reverting to the default.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

public class Form1 : System.Windows.Forms.Form
private System.Windows.Forms.SplitContainer splitContainer1;

// Create an empty Windows form.
public Form1()
	private void InitializeComponent()
        splitContainer1 = new System.Windows.Forms.SplitContainer();

        // Place a basic SplitContainer control onto Form1.
        splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
        splitContainer1.Location = new System.Drawing.Point(0, 0);
        splitContainer1.Name = "splitContainer1";
        splitContainer1.Size = new System.Drawing.Size(292, 273);
        splitContainer1.SplitterDistance = 52;
        splitContainer1.SplitterWidth = 6;
        splitContainer1.TabIndex = 0;
        splitContainer1.Text = "splitContainer1";

        // Add the event handler for the SplitterMoved event.
        splitContainer1.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(splitContainer1_SplitterMoved);

        // Add the event handler for the SplitterMoving event.
        splitContainer1.SplitterMoving += new System.Windows.Forms.SplitterCancelEventHandler(splitContainer1_SplitterMoving);

        // This is the left panel of the vertical SplitContainer control.
        splitContainer1.Panel1.Name = "splitterPanel1";

        // This is the right panel of the vertical SplitContainer control.
        splitContainer1.Panel2.Name = "splitterPanel2";

        // Lay out the basic properties of the form.
        ClientSize = new System.Drawing.Size(292, 273);
        Name = "Form1";
        Text = "Form1";

	static void Main() 
		Application.Run(new Form1());

    private void splitContainer1_SplitterMoved(System.Object sender, System.Windows.Forms.SplitterEventArgs e)
    // Define what happens when the splitter is no longer moving.

    private void splitContainer1_SplitterMoving(System.Object sender, System.Windows.Forms.SplitterCancelEventArgs e)
    // Define what happens while the splitter is moving.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.