Reputation: 1523
I am having trouble setting splitContainer
sizes depending on my Form size.
When my form is loaded it is at a MinimumSize
of 1170,930
. But if I resize my form both .SplitterDistance
and .Panel2MinSize
are at different places then where they should be.
I have tried the following using the Form_SizeChanged
event but it is not working correctly. Is there a way I can calculate .SplitterDistance
and .Panel2MinSize
to cater for the form resize.
private void MainForm_SizeChanged(object sender, EventArgs e)
{
int x = this.Size.Height;
int y = this.MinimumSize.Height;
splitContainer1.SplitterDistance = splitContainer1.SplitterDistance + (x - y);
splitContainer1.Panel2MinSize = splitContainer1.Panel2MinSize + (x - y);
}
Thanks in advance.
EDIT
Added some pics to give a better example below.
Form Standard (what it should look like)
Form Resized
Upvotes: 1
Views: 2460
Reputation: 66459
It looks like you want to keep one of the Panels the same size, moving the splitter as the Form is resized.
There's a property to tell it whether the first or second Panel should remain "fixed" when resizing:
splitContainer1.FixedPanel = FixedPanel.Panel2; // or FixedPanel.Panel1
Upvotes: 3