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 between two panels

Splitter between two panels

Scheduled Pinned Locked Moved C#
helptutorial
8 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.
  • V Offline
    V Offline
    VPMahank
    wrote on last edited by
    #1

    Can we have a splitter between two panels. one panel's dock property is set to left and other ones set to fill. The splitter does not seem to work properly for the panels I suppose. Any ideas on how to approach the problem would be appreciated. Thanks, VPMahank

    D M 2 Replies Last reply
    0
    • V VPMahank

      Can we have a splitter between two panels. one panel's dock property is set to left and other ones set to fill. The splitter does not seem to work properly for the panels I suppose. Any ideas on how to approach the problem would be appreciated. Thanks, VPMahank

      D Offline
      D Offline
      Darryl Borden
      wrote on last edited by
      #2

      I have run into this same issue. I resolved it by creating my own "splitter" (a very narrow panel control) and keyed off its mouse events (mousedown, mousemove, mouseup), then moved the affected panels accordingly. Darryl Borden Principal IT Analyst dborden@eprod.com

      V 2 Replies Last reply
      0
      • D Darryl Borden

        I have run into this same issue. I resolved it by creating my own "splitter" (a very narrow panel control) and keyed off its mouse events (mousedown, mousemove, mouseup), then moved the affected panels accordingly. Darryl Borden Principal IT Analyst dborden@eprod.com

        V Offline
        V Offline
        VPMahank
        wrote on last edited by
        #3

        Thanks for the idea Darryl. I will try it out. Thanks, VPMahank:)

        1 Reply Last reply
        0
        • D Darryl Borden

          I have run into this same issue. I resolved it by creating my own "splitter" (a very narrow panel control) and keyed off its mouse events (mousedown, mousemove, mouseup), then moved the affected panels accordingly. Darryl Borden Principal IT Analyst dborden@eprod.com

          V Offline
          V Offline
          VPMahank
          wrote on last edited by
          #4

          I tried your suggestion. The idea works!!!. But the painting is not done neatly. I mean I have a inherited panel and I did set the styles to enable doubleBuffering. But using those panels would not paint properly when using the spiltter( I inherited splitter control from label and set the styles for this too). Please let me know if I am missing anything. Thanks, VPMahank.

          D 1 Reply Last reply
          0
          • V VPMahank

            I tried your suggestion. The idea works!!!. But the painting is not done neatly. I mean I have a inherited panel and I did set the styles to enable doubleBuffering. But using those panels would not paint properly when using the spiltter( I inherited splitter control from label and set the styles for this too). Please let me know if I am missing anything. Thanks, VPMahank.

            D Offline
            D Offline
            Darryl Borden
            wrote on last edited by
            #5

            Are you resizing your panels as you move your splitter? I did not do it that way. I would allow the user to move my splitter (panel) then when they release I then resize the other panels. I'm not sure what you did with "I inherited splitter control from label...". I just dropped a panel on my form, made it very narrow (so it looks like a splitter) and allow the user to click on it and drag it to the desired location and release it. At that point, I just resize the panels affected by the new location of the splitter. Darryl Borden Principal IT Analyst dborden@eprod.com

            1 Reply Last reply
            0
            • V VPMahank

              Can we have a splitter between two panels. one panel's dock property is set to left and other ones set to fill. The splitter does not seem to work properly for the panels I suppose. Any ideas on how to approach the problem would be appreciated. Thanks, VPMahank

              M Offline
              M Offline
              MF
              wrote on last edited by
              #6

              You havn't described "How it doesn't work". I has used it and everything is expected.

              V 2 Replies Last reply
              0
              • M MF

                You havn't described "How it doesn't work". I has used it and everything is expected.

                V Offline
                V Offline
                VPMahank
                wrote on last edited by
                #7

                Ok what I was doing was a little different. I was resizing the panel each time the splitter is moved. So the two panels were resizing each time the MouseMove of the splitter is called. The problem with this the panel resizing is not done smoothly as required. I tried making a few changes to the code now. Relocating the splitter location in mouse move and relocating and resizing the panels in the mouseup. Here is what I did. Please let me know if I can improve this anymore and allow a cleaner dispaly. public class NoDockSplitter : Label { public NoDockSplitter() { // set styles to prevent flickering SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyles(); } protected void SetStyles() { this.BorderStyle = BorderStyle.None; this.Text = "|"; this.TextAlign = ContentAlignment.MiddleCenter; } protected Control _leftSideControl; protected Control _rightSideControl; public Control LeftSideControl { get { return _leftSideControl; } set { _leftSideControl =value; SetControlSize(_leftSideControl); } } public Control RightSideControl { get { return _rightSideControl; } set { _rightSideControl =value; SetControlSize( _rightSideControl); } } protected bool _mouseDown = false; protected bool _sizeSet = false; protected int _leftSideControlWidth = 0; protected int _rightSideControlWidth = 0; protected int _rightSideControlXPos = 0; protected int _splitterStartXPos = 0; protected bool _widthSet = false; protected int _diff = 0; protected int _startXPos = 0; protected void SetControlSize(Control c) { if(! _sizeSet ) { this.Size = new Size( 4, c.Height); _sizeSet = true; } } protected override void OnMouseEnter(EventArgs e) { base.OnMouseEnter (e); this.Cursor = Cursors.VSplit; if( !_widthSet) { _leftSideControlWidth = _leftSideControl.Width; _rightSideControlWidth = _rightSideControl.Width; _rightSideControlXPos = _rightSideControl.Location.X; _splitterStartXPos = this.Location.X; _widthSet = true; } } protected override void OnMouseLeave(EventArgs e) { base.OnMouseLeave (e); this.Cursor = Cursors.Default; } protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown (e); _mouseDown = true; _diff = 0

                1 Reply Last reply
                0
                • M MF

                  You havn't described "How it doesn't work". I has used it and everything is expected.

                  V Offline
                  V Offline
                  VPMahank
                  wrote on last edited by
                  #8

                  My additional need was to have a splitter between controls that are not docked at all. So I need a control that behaves like a splitter but for undocked controls. Thanks, VPMahank

                  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