Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
Load Layout From XML when xml is incompatible

Is there a way to attempt to load layout from xml but make it fail if the xml specifies panes or controls that don't exist on your form or when there are controls that are docked in your form that aren't specified in the xml.

 The situation I'm in is that I did some development, saved my layout, added a new control and docked it. Then at runtime when I load from xml it is quite happy to accept the old saved layout and the initially docked control is left undocked in the middle of my form. I want it to throw an exception if any previously docked controls are left undocked as the result of a load.

No Data
  • 44743
    Verified Answer

    It sounds like the best thing to do here would be to build a list of docked controls before loading your layout, then verify they are all still docked after loading the layout. To build the list, you can iterate over the ControlPanes collection of the dock manager. For each DockableControlPane, store its Control in a collection. After loading the layout, iterate the ControlPanes collection again, this time removing each pane's Control from the collection. If your collection has any items left over, they were not all loaded back into the dock manager.

No Data