We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Prevent Splitter from closing

I am using vs 3.201.1.515 of the grid control inside a TabBarSplitterControl. What is the easiest way to prevent closing of a pane? There is no way to cancel the PaneClosing event. I would like to prevent the PaneClosing event from destroying the grid control. Thanks, Per

3 Replies

AD Administrator Syncfusion Team August 24, 2005 04:01 PM UTC

The only way I know to do this is to derive the control and ignore the MouseUp if it is outside the grid. Here is a try at this. You will want to tweak the values to get the behavior you want.
public class MySplitterControl : SplitterControl
{
	private Point downPT;
	protected override void OnMouseDown(MouseEventArgs e)
	{
		downPT = new Point(e.X, e.Y);
		base.OnMouseDown (e);
	}

	protected override void OnMouseUp(MouseEventArgs e)
	{
		Point pt = new Point(e.X, e.Y);
		if(pt.Y < 40 || pt.Y > this.Height - 40
			|| pt.X < 40 || pt.X > this.Width - 4)
		{
			MouseEventArgs e1 = new MouseEventArgs(e.Button, e.Clicks, downPT.X, downPT.Y, e.Delta);
			base.OnMouseUp(e1);
			return;
		}
		base.OnMouseUp (e);
	}
}


AD Administrator Syncfusion Team August 24, 2005 07:01 PM UTC

Thanks Clay, The OnMouseDown event only seems to fire when I "create" the pane by dragging the splitter from the lower right corner. If I release the splitter and then click on it again (this time in the middle of the screen) the OnMouseDown event does not fire. I hope this makes sense. Any other ideas? Thanks Per >The only way I know to do this is to derive the control and ignore the MouseUp if it is outside the grid. Here is a try at this. You will want to tweak the values to get the behavior you want. >
>public class MySplitterControl : SplitterControl
>{
>	private Point downPT;
>	protected override void OnMouseDown(MouseEventArgs e)
>	{
>		downPT = new Point(e.X, e.Y);
>		base.OnMouseDown (e);
>	}
>
>	protected override void OnMouseUp(MouseEventArgs e)
>	{
>		Point pt = new Point(e.X, e.Y);
>		if(pt.Y < 40 || pt.Y > this.Height - 40
>			|| pt.X < 40 || pt.X > this.Width - 4)
>		{
>			MouseEventArgs e1 = new MouseEventArgs(e.Button, e.Clicks, downPT.X, downPT.Y, e.Delta);
>			base.OnMouseUp(e1);
>			return;
>		}
>		base.OnMouseUp (e);
>	}
>}
>


AD Administrator Syncfusion Team August 24, 2005 07:45 PM UTC

If I put a Console.WriteLine("OnMouseDown"); in the override, I see it hit when I click on a existing splitter in the middle. Am I missing your point? http://www.syncfusion.com/Support/user/uploads/CS_259b50aa.zip

Loader.
Live Chat Icon For mobile
Up arrow icon