Search code examples
c#.neteventssplitcontainer

Handle event in splitter area of splitcontainer control


Is there any trivial way to handle click event on the splitter area of the WinFroms splitcontainer control? (symbolized by blue in my picture) E.g. I'd like to collapse panel1 by double clicking this area.

Or another possibility to put some nice button in this area and by clicking it I can collapse panels.

I don't wanna great hack to make a soulution, it would be nice to have a trivial one.

Thx

(.net 4/c#/VS2010)

enter image description here


Solution

  • You should be able to use the SplitContainer.DoubleClick event for this purpose..

      splitContainer1.DoubleClick += splitContainer1_DoubleClick;
    

    and

        private void splitContainer1_DoubleClick(object sender, EventArgs e)
        {
            splitContainer1.Panel1Collapsed = true;
        }
    

    If you want the location of the click, use MouseDoubleClick event which comes with MouseEventArgs for the event handler.