0

I have a form with multiple splittConteiners. I have set a default position for the splitters. I allow the user to move the splitters. Before closing the form I store in the app config the splitter distance, width and heigh of all the splitters. When I open the control I Set the splitters to the stored data.

BUT after the load, the position of the splitters is not the same. Any ideas to solve it?

Here is de the code used to save and load the value:

public static int ConsultaSplitterPrincipal
        {
            get { return int.Parse(ConfigurationManager.AppSettings["SplitterDistancePrincipal"]); }
            set { ConfigurationManager.AppSettings.Set("SplitterDistancePrincipal", value.ToString()); }
        }
Guillermo
  • 11
  • 6
  • In app.config? Or Project's Settings? Post your code, how/where/when/what you save and load. Note that you can just add a ProperyBinding to the `SplitterDistance` property as described [here](https://stackoverflow.com/a/61160815/7444103). After that, it's all automatic. – Jimi Sep 01 '20 at 04:31
  • I try the example way, but the position still changes. Something else is happening. – Guillermo Sep 01 '20 at 12:00
  • Possible. If your app is not DpiAware, set the Forms' `AutoScaleMode = Dpi`, apply this: [How to configure an app to run correctly on a machine with a high DPI setting](https://stackoverflow.com/a/13228495/7444103). If it's now working as expected, read here: [High DPI support in Windows Forms](https://learn.microsoft.com/en-us/dotnet/framework/winforms/high-dpi-support-in-windows-forms) for improvements. You .Net Framework version should be 4.7.2 to use the Windows10 improvements at their best. – Jimi Sep 01 '20 at 12:08
  • I know that refactoring an app to be DpiAware is not hassle-free, but it's a required change (it has been for quite a long time now). If that solves the problem, of course. – Jimi Sep 01 '20 at 12:10

0 Answers0