WinForms: Alternative to SplitContainer?

Write your own split container UserControl. You basically just drop two Panels onto the control (for the left and right panels) and then let the space between them be the splitter. A little MouseDown, MouseMove and MouseUp logic on the UserControl itself will let you easily move the "splitter" left and right, and the two panels will properly block this everywhere but over the splitter, so your logic for checking if the mouse if over the splitter is as simple as can be.

It may be a little extra work getting the control to act the way you want it to act in design mode.


I found this after I saw your question, so thought I would share: SplitContainer FAQ

The second link on there tells exactly what you need to do.

Here is the text from that just in case the link ever dies.

//1.  Use the custom control defined in the SplitContainerNoFocus sample
//2. Insert the following code in your project, and attach these events to all of the SplitContainers that you don't want stealing focus.

// Temp variable to store a previously focused control
private Control focused = null; 

private void splitContainer_MouseDown(object sender, MouseEventArgs e)
{
   // Get the focused control before the splitter is focused
   focused = getFocused(this.Controls);
}

private Control getFocused(Control.ControlCollection controls)
{
   foreach (Control c in controls)
   {
      if (c.Focused)
      {
         // Return the focused control
         return c;
      }
      else if (c.ContainsFocus)
      {
         // If the focus is contained inside a control's children
         // return the child
         return getFocused(c.Controls);
      }
   }
   // No control on the form has focus
   return null;
}

private void splitContainer_MouseUp(object sender, MouseEventArgs e)
{
   // If a previous control had focus
   if (focused != null)
   {
      // Return focus and clear the temp variable for 
      // garbage collection
      focused.Focus();
      focused = null;
   }
}