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.
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).
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
door access control system