Split Container SplitterDistance changes without user intervention

.net, splitcontainer, winforms

Solution

Do you have user controls inside the split container , and probably when they are all loaded it would resized along with the user controls which contain it.

To troubleshoot that, set a FixedPanel Property and observe it.

Problem

My Winforms app saves and restores its GUI state in the database. Everything's working ok, except for a Split Container's SplitterDistance. The value is correctly loaded and set from DB, but when I exit the app without touching the splitter, I expect it to save the same value. But it saves the initial value minus 25 pixels. If I open and close the app many times, the splitter distance decreases by 25 pixels every time. It's not a custom control, just a plain old .NET SplitContainer. The control is only accessed programatically to load its initial SplitterDistance and save it on exit, nothing else. How can I troubleshoot this? UPDATE: The spl's `FixedPanel` property was originally set to `None`. Tried setting it to `Panel1` and `Panel2`; in both cases, SplitterDistance grows 50 pixels when I save it.

Original source