3

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

Tom
  • 3,899
  • 22
  • 78
  • 137

2 Answers2

4

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.

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • I don't want it. I want collapse only by double clicking of 'splitter area' (symbolized by blue in my pic) – Tom Jun 22 '11 at 21:22
  • @Tom the DoubleClick event fires only when you double click on the splitter and not the panels. – Bala R Jun 22 '11 at 21:24
  • Sorry about that I thought it was fired by anywhere on the container. I confused some things in my code and handled panel double click. Sorry for that I am tired. – Tom Jun 22 '11 at 21:28
  • I am trying to implement hide/show left panel (`Panel1Collapsed`) trigger with `SplitContainer.DoubleClick` event. Hiding works properly, but I can not show it: V-Splitter is invisible and event can not be fired. Is there workaround? – hellboy Mar 10 '16 at 10:06
0

You mean besides the SplitContainer's Click event?

mbeckish
  • 10,485
  • 5
  • 30
  • 55
  • Click event fires when clicking on the whole area of the container and as I know it does not give information about the exact place of the clicking. I can have point info, but it does not tell me the 'blue' are was clicked. – Tom Jun 22 '11 at 21:21