Reputation: 16060
I have a form with a splitcontainer.At runtime the user can switch between vertical and orizontal,when switching the size of the panel are not the same and one side you can barely see anything unless a user makes it bigger.
What properties can I set to make both panels to be the same size when they switch between orientation?
Many thanks
Upvotes: 1
Views: 3454
Reputation: 54433
When you change the Orientation try this:
splitContainer1.SplitterDistance =
(splitContainer1.Orientation == Orientation.Vertical?
splitContainer1.Width : splitContainer1.Height) / 2;
or of course simply, when setting to horizontal:
splitContainer1.SplitterDistance = splitContainer1.Height / 2;
..and when setting to vertical:
splitContainer1.SplitterDistance = splitContainer1.Width / 2;
..respectively.
(Note I have now erred twice on the Orientation, sigh. I guess it's just not as simple as it looks ;-))
Upvotes: 3