Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Splitter control, resize immediately?

Splitter control, resize immediately?

Scheduled Pinned Locked Moved C#
csharpphpcomquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Druuler
    wrote on last edited by
    #1

    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[^]

    L A 2 Replies Last reply
    0
    • D Druuler

      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[^]

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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).


      D 1 Reply Last reply
      0
      • L Luc Pattyn

        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).


        D Offline
        D Offline
        Druuler
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • D Druuler

          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.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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).


          1 Reply Last reply
          0
          • D Druuler

            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[^]

            A Offline
            A Offline
            Alan N
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups