KB Article A2860
Visible to All Users

How the splitter's position can be saved on exit and restored when the application is launched next time

Description:
I'm using the SplitContainerControl component on a UserControl. The UserControl is dynamically loaded and disposed of. I want to save the SplitterPosition's value and restore it, so that an end-user's customization persists. Do you have a suggestion as to how to implement this feature?

Answer:
Custom data is easy to save by utilizing Serialization technology. You can implement a class with some fields and mark it with the Serializable attribute. After that, you can save and load these settings when necessary.
It may be difficult to determine exactly when to load settings. The SplitContainerControl must be created, docked and resized. If the SplitterPosition property is assigned before the control is resized, the actual value will be different when the control becomes visible, because the SplitterPosition is changed proportionally to the control's size. We advise that you try to use the Layout event of your UserControl to determine the moment when the settings can be loaded and assigned to the inner controls.
Please explore the corresponding example. Here are the step-by-step instructions:

  1. Launch the sample.
  2. Press the Load module button.
  3. Change the splitter position.
  4. Press the Unload module button.
  5. Press Load module - the splitter position is restored.
    When the module is loaded or destroyed, the SplitterPosition value is logged in the Output window.
Comments (2)

    is there a sample for this ?

    DevExpress Support Team 11 years ago

      Hi,
      We have the How the splitter's position can be saved on exit, and restored when the application is next launched example implementing this approach. You can also find it in the orange Examples section to the right of this ticket.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.