Hi,
I performed a test based on your description and did reproduce the problem
on my side.
If you set a break point on the line of code
'Me.mySplitContainer.Panel1MinSize = 400' and run the application by
pressing F5, you should observe the following values of properties when
this break point is hit:
SplitContainer.Width = 150 (this is the default value)
SplitContainer.SplitterWidth = 4 (this is the default value)
SplitContainer.Panel1MinSize = 25 (this is the default value)
SplitContainer.Panel2MinSize = 25 (this is the default value)
SplitContainer.SplitterDistance = 50 (this is the default value)
Press F10 and the values of these properties become:
SplitContainer.Width = 150 (this is the default value)
SplitContainer.SplitterWidth = 4 (this is the default value)
SplitContainer.Panel1MinSize = 400
SplitContainer.Panel2MinSize = 25 (this is the default value)
SplitContainer.SplitterDistance = 121
As we can see, the value of 121 for the SplitterDistance is calculated from
the formula below:
SpliterContainer.Width - SplitContainer.SplitterWidth -
SplitContainer.Panel2MinSize
that is, 150 - 4 - 25 = 121
Keep pressing F10 until the line of code 'Me.mySplitContainer.Panel2MinSize
= 369' is hit. You should see the values of the properties remain the same
as before.
Press F10 and this line of code is executed and then you get an
InvalidOperationException.
This is because when the new value set to the Panel2MinSize property is
bigger than the Panel2.Width, the SplitContainer tries to adjust the value
of the SplitterDistance property according to the new Panel2MinSize
property value. However, at this time, the value of the
SplitContainer.Width is still the default value 150, but that of the
Panel2MinSize property becomes 369. According to the formula
"SpliterContainer.Width - SplitContainer.SplitterWidth -
SplitContainer.Panel2MinSize", the calculation result is a negative value
which is not valid, so the InvalidOperationException is thrown.
The workaround of this problem is simple, i.e. reset the value of the
Panel2MinSize property (i.e. set its value to 25), or set the Panel2MinSize
property to a value less than or equal to 146.
Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.