Splitter control, resize immediately?
-
in windows vista and windows 7 the splitter control used in explorer windows doesnt draw the "hatched line" when it moves instead the controls (listview and treeview) automatically resizes immediately, i want the splitter control in .net to behave like that but cant really figure out how? heres a pic of the hatched line: http://sv.tinypic.com/view.php?pic=2qa8izk&s=6[^]
-
in windows vista and windows 7 the splitter control used in explorer windows doesnt draw the "hatched line" when it moves instead the controls (listview and treeview) automatically resizes immediately, i want the splitter control in .net to behave like that but cant really figure out how? heres a pic of the hatched line: http://sv.tinypic.com/view.php?pic=2qa8izk&s=6[^]
Hi, I've been looking into the internals of SplitContainer, using .NET Reflector; it seems like a live SplitterMoving isn't supported at all. My guess is you need to (create and) use another Control if you want live splitter movements. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
Hi, I've been looking into the internals of SplitContainer, using .NET Reflector; it seems like a live SplitterMoving isn't supported at all. My guess is you need to (create and) use another Control if you want live splitter movements. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
thanks for your reply, but i think ive fixed it. :) the solution is pretty ugly but it works, all i did was overide OnSplitterMoving and set the Splitter.SplitPostion = sevent.X or sevent.Y and then just invalidate the splitter. also invalidate OnMouseDown and OnMouseUp to get rid of the hatched line which showed up until the mouse was moved.
-
thanks for your reply, but i think ive fixed it. :) the solution is pretty ugly but it works, all i did was overide OnSplitterMoving and set the Splitter.SplitPostion = sevent.X or sevent.Y and then just invalidate the splitter. also invalidate OnMouseDown and OnMouseUp to get rid of the hatched line which showed up until the mouse was moved.
Very good. Sounds like that logic too deserves to be hidden into a specialized SplitContainer. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
-
in windows vista and windows 7 the splitter control used in explorer windows doesnt draw the "hatched line" when it moves instead the controls (listview and treeview) automatically resizes immediately, i want the splitter control in .net to behave like that but cant really figure out how? heres a pic of the hatched line: http://sv.tinypic.com/view.php?pic=2qa8izk&s=6[^]
Hi, Your fix mentioned in the response to Luc prompted me to look into this again. I'd given up once before as I had got nowhere fast. The trick is to disable the default handling of the splitter by cancelling the SplitterMoving event. Once that is done the splitter position can be set explicitly in the MouseMove event. Redrawing is automatic and no invalidation is required. This is what I have
private Boolean mouseDown = false;
....
splitContainer.MouseMove += SplitContainer_MouseMove;
splitContainer.MouseDown += SplitContainer_MouseDown;
splitContainer.MouseUp += SplitContainer_MouseUp;
splitContainer.SplitterMoving += SplitContainer_SplitterMoving;
....private void SplitContainer_MouseDown(object sender, MouseEventArgs e) {
mouseDown = true;
}private void SplitContainer_MouseUp(object sender, MouseEventArgs e) {
mouseDown = false;
}private void SplitContainer_SplitterMoving(object sender, SplitterCancelEventArgs e) {
// prevent default action
e.Cancel = true;
}private void SplitContainer_MouseMove(object sender, MouseEventArgs e) {
SplitContainer sc = (SplitContainer)sender;
if (mouseDown) {
if (sc.Orientation == Orientation.Horizontal) {
if (e.Y >= 0) {
sc.SplitterDistance = e.Y;
}
} else {
if (e.X >= 0) {
sc.SplitterDistance = e.X;
}
}
}
}Alan.