Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

SplitContainer.SplitterMoved Event

Note: This event is new in the .NET Framework version 2.0.

Occurs when the splitter control is moved.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public event SplitterEventHandler SplitterMoved
/** @event */
public void add_SplitterMoved (SplitterEventHandler value)

/** @event */
public void remove_SplitterMoved (SplitterEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

For more information about event handler delegates, see Events and Delegates. For more information about handling events, see Consuming Events.

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()
	{
	InitializeComponent();
	}
	private void InitializeComponent()
	{
        splitContainer1 = new System.Windows.Forms.SplitContainer();
        splitContainer1.SuspendLayout();
        SuspendLayout();

        // 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);
        Controls.Add(splitContainer1);
        Name = "Form1";
        Text = "Form1";
        splitContainer1.ResumeLayout(false);
        ResumeLayout(false);

    }
	[STAThread]
	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.
    Cursor.Current=System.Windows.Forms.Cursors.Default;
    }

    private void splitContainer1_SplitterMoving(System.Object sender, System.Windows.Forms.SplitterCancelEventArgs e)
    {
    // Define what happens while the splitter is moving.
    Cursor.Current=System.Windows.Forms.Cursors.NoMoveVert;
    }
}

import System.*;
import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;

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

    // Create an empty Windows form.
    public Form1()
    {
        InitializeComponent();
    } //Form1

    private void InitializeComponent()
    {
        splitContainer1 = new System.Windows.Forms.SplitContainer();
        splitContainer1.SuspendLayout();
        SuspendLayout();
        // Place a basic SplitContainer control onto Form1.
        splitContainer1.set_Dock(System.Windows.Forms.DockStyle.Fill);
        splitContainer1.set_Location(new System.Drawing.Point(0, 0));
        splitContainer1.set_Name("splitContainer1");
        splitContainer1.set_Size(new System.Drawing.Size(292, 273));
        splitContainer1.set_SplitterDistance(52);
        splitContainer1.set_SplitterWidth(6);
        splitContainer1.set_TabIndex(0);
        splitContainer1.set_Text("splitContainer1");
        // Add the event handler for the SplitterMoved event.
        splitContainer1.add_SplitterMoved(new System.Windows.Forms.
            SplitterEventHandler(splitContainer1_SplitterMoved));
        // Add the event handler for the SplitterMoving event.
        splitContainer1.add_SplitterMoving(new System.Windows.Forms.                                   SplitterCancelEventHandler(splitContainer1_SplitterMoving));
        // This is the left panel of the vertical SplitContainer control.
        splitContainer1.get_Panel1().set_Name("splitterPanel1");
        // This is the right panel of the vertical SplitContainer control.
        splitContainer1.get_Panel2().set_Name("splitterPanel2");
        // Lay out the basic properties of the form.
        set_ClientSize(new System.Drawing.Size(292, 273));
        get_Controls().Add(splitContainer1);
        set_Name("Form1");
        set_Text("Form1");
        splitContainer1.ResumeLayout(false);
        ResumeLayout(false);
    } //InitializeComponent

    /** @attribute STAThread()
     */
    public static void main(String[] args)
    {
        Application.Run(new Form1());
    } //main

    private void splitContainer1_SplitterMoved(System.Object sender, 
        System.Windows.Forms.SplitterEventArgs e)
    {
        // Define what happens when the splitter is no longer moving.
        get_Cursor().set_Current(System.Windows.Forms.Cursors.get_Default());
    } //splitContainer1_SplitterMoved

    private void splitContainer1_SplitterMoving(System.Object sender, 
        System.Windows.Forms.SplitterCancelEventArgs e)
    {
        // Define what happens while the splitter is moving.
        get_Cursor().set_Current(System.Windows.Forms.Cursors.get_NoMoveVert());
    } //splitContainer1_SplitterMoving
} //Form1

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft