SplitterDistance must be between Panel1MinSize and Width - Panel2MinSize

I researched this issue for the benefits of my development work for time attendance system with door access control capability.


To solve this problem, instead of setting the 'SplitterDistance' property value to a fixed value, use a formula.

SplitContainer1.SplitterDistance = ((Me.SplitContainer1.Width _ 
                                           - Me.SplitContainer1.Panel2MinSize) _
                                           + Me.SplitContainer1.Panel1MinSize) _
                                           * (30 / 100)

Using this formula, you can make sure that the value will fall within proper range, then using a percentage to vary the value within that range. In the case above, the percentage used will be 30%.

Two things to take note.

I) If you are using Horizontal split, you must use 'height' instead of 'width'. The exception message will still show you that it is related to the 'width', but it should be 'height' instead.



II) Do not change the splitterDistance property value if the form is being minimized, this is because when form is minimized, the formula will derive a zero value which then it will violate the same error again.


Download the sample code in VB.NET (Visual Studio 2008 SP1).

Comments

Unknown said…
This comment has been removed by a blog administrator.
Unknown said…
Access control is also a key feature of Anytime Fitness Security because the system has a tailgating detection device that sounds an alarm when more than one person has made use of key card or has entered the door without one. Their access control provides each member and staff with a unique key card that is registered into a software that triggers the doors to open and close.

door access control system