views:

242

answers:

0

I use Visual Studio (C#) 2008

I've got a SplitContainer - each of its two panels contains one datagridview. The user can resize the panels by dragging the splitter up and down.

I'd like to implement the "snap" effect - whenever the splitter gets close to the edge of one of the datagridviews, it would "get caught", so that the grid fits just fine and occupies precisely 100% of the resized panel.

How can I do that?

I easily managed to get it working in the way that the splitter "snaps" as soon as user RELEASES the mouse button (when SplitterMoved event occurs).

But I'd like this effect to be visible to the user when the mouse button is still down, so that the user can see in advance that it works that way, and doesn't worry about being precise. Otherwise it kind of defeats the very purpose of it.

So, basically I'd like that "shadow" of the dragged splitter to snap already.

This should be done in the SplitterMoving event I guess.

But that event does not seem to allow for such functionality.

The SplitterCancelEventArgs do not exhibit any property which would let me re-position the "shadow".

Is it possible then??

It doesn't sound like some very fancy feature to me, so I'm a bit surprised that there's no obvious way to do it...