Reputation: 11
In my windows application, I have docked a panel to the right which has a group box and cancel & print buttons. I have another panel with a button and groupbox and on button click, group box location is changed to make it a custom slider which has to be placed above this panel. I couldn't place the slider panel inside this right docked panel, because width differs.
I could place the slider panel without docking above this right docked panel. But when window resizes,all docked panels are resized accordingly except this slider panel.
Designer code for right docked panel.
this._pnlBasicPanelRight.Controls.Add(this._pnlBottomButtons);
this._pnlBasicPanelRight.Controls.Add(this._tgbxLocation);
this._pnlBasicPanelRight.Dock = System.Windows.Forms.DockStyle.Right;
this._pnlBasicPanelRight.Location = new System.Drawing.Point(1105, 0);
this._pnlBasicPanelRight.Name = "_pnlBasicPanelRight";
this._pnlBasicPanelRight.Size = new System.Drawing.Size(167, 693);
this._pnlBasicPanelRight.TabIndex = 44;
designer code for slider panel
this._pnlDataGrid.Dock = System.Windows.Forms.DockStyle.Right;
this._pnlDataGrid.Controls.Add(this._tgrpLimitValues,1,0);
this._pnlDataGrid.Controls.Add(this._btnRightBottomPanelVisibility,0,0);
this._pnlDataGrid.Size = new System.Drawing.Size(483, 370);
this._pnlDataGrid.Location = new System.Drawing.Point(1310, 159);
this._pnlDataGrid.Name = "_pnlDataGrid";
this._pnlDataGrid.TabIndex = 44;
This is how i need my right panel to look like
Upvotes: 0
Views: 1238
Reputation: 74595
Looking at the picture you've posted I would forget docking (dock:none) and I would instead position the panels as you have done in your image and then set the anchor properties:
Anchor means "keep the same distance between the chosen edge and the same edge of the enclosing container"
This means your top right panel will move left and right when the window is resized bigger but it will not move down or grow larger. The bottom right panel will also move left and right, will not move up and down, but it will grow vertically as the window grows
If instead you want the bottom right panel to be a fixed size and the top panel to grow vertically:
This will make the bottom right panel a fixed size and glued into the bottom right of the window (moves up down left right, doesn't grow) and the top right panel will move left and right, won't grow horizontally but will grow and shrink vertically as the window height changes
Upvotes: 0
Reputation: 74595
Docking something sticks it to the right of its container and occupies the full height. You can't have two panels fighting for occupation of the full height and they don't know about each other so they won't intrinsically play nicely and divide up the space (there is no mechanism to apportion space)
You'll need to use a device that knows how to have two things taking up a height and can apportion space, such as a SplitContainer with a horizontal divide mode. Dock the splitcontainer to the right and put your two panels inside it, one on either side of the splitter
Upvotes: 2