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
20
Prevent Grid from resetting column properties on datasource change
posted

Hope someone out there can help me. This is my scenario: I've got a Grid with a BindingSource as its datasource.  The BindingSource's datasource is a list of business objects.  This works great, I can set my visible columns, change captions etc.  But when I make a change the the underlying business object all of my changes in the grid are lost.  Is there any way to prevent the grid from changing when the business object is changed? 

I know I can save and reload the grid layout with the layout wizard, but with the number of grids I'm working on keeping an up-to-date copy of the layout to reload is more of a hassel then resetting the required column properties manually.

 Thanks 

Parents
No Data
Reply
  • 375
    posted

    Hi,

    maybe this will help:

    BindingSource bs = new BindingSource();

    bs.SuspendBinding();

    // make changes to the business object here

    bs.ResumeBinding();

    Or add a value called _isInternalManipulation

    private bool _isInternalManipulation = false;

    and call the NotifyPropertyChange method in the set accessor only if _isInternalManipulation is true. When you want to manipulate a property of the business value internal, set _isInternalManupulation = true first and change the property after. At the end set the _isInternalManipulation to false.

    Hope this will help.

    Kind regards

    Ralf

Children
No Data