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