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.
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
Thanks.
I don't have to save and reload as much as I thought. If the grid's datasource is set to nothing you loose the layout. However, I am binding to a collection and I can clear the collection. Then reload the collection. Did find that I had to tell the grid to update and set active row to nothing on the grid. With out this the active row does not change and we are binding the current object in the collection on AfterActiveRowChanged event. This does not fire if you do not update the grid or set active row to nothing this only happens if the previous active row index is 1. New active row index is also 1 so no changed event.
Dan