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
195
Method to tell if the DisplayLayout has changed?
posted

Is there a method/property to tell if a display layout has changed.  I am loading the grid's display layout from a file and would only like to save the layout if it has changes.

Parents
No Data
Reply
  • 37774
    Verified Answer
    posted

    The easiest way to see if there are any non-default values on an UltraGridLayout object is to check the ShouldSerialize method.  Unfortunately, this method has an 'internal protected' access modifier, so the only way to get at it is through reflection:

    MethodInfo methodInfo = typeof(UltraGridLayout).GetMethod("ShouldSerialize", BindingFlags.Instance | BindingFlags.NonPublic);
    bool hasNonDefaultValues = (bool)methodInfo.Invoke(this.ultraGrid1.DisplayLayout, null);

    Since the layout also serializes the Override object, you'll need to do the same thing for the DisplayLayout.Override.

    It seems that I misread your question in haste.  There is not any way to determine if the layout has been changed since you have loaded your previous layout from a file since the grid does not keep track of this.  I had misread your question (and by misread I mean skipped the part about loading from a file) to be if they've changed anything at all from the defaults.  The most efficient way is to simply always save the layout, since your only other alternative is to save the layout to a temporary stream and compare each byte to see if it's changed from the old layout, which is naturally very inefficient.

    -Matt

Children