Rockford Lhotka
    CTO at Magenic
    Author, speaker, software architect
    Creator of the CSLA .NET framework

Home
Blog
CSLA .NET
Magenic
Speaking
Publications
About me
Contact me

Login

C# p 116-120 (UnbindBindingSource, Save,Apply,Close,Cancel buttons)

 

On page 116, the UnbindBindingSource() method is incorrect. It should accept an "apply" parameter as follows:

    protected void UnbindBindingSource(BindingSource source, bool apply, bool isRoot)

    {

      System.ComponentModel.IEditableObject current =

        source.Current as System.ComponentModel.IEditableObject;

      if (isRoot)

        source.DataSource = null;

      if (current != null)

        if (apply)

          current.EndEdit();

        else

          current.CancelEdit();

    }

On pages 117-120 the calls to UnbindBindingSource() have their second parameters reversed.

When calling from Save or Apply the calls should be:

        UnbindBindingSource(this.resourcesBindingSource, true, false);

        UnbindBindingSource(this.projectBindingSource, true, true);

When calling from Close or Cancel the calls should be:

        UnbindBindingSource(this.resourcesBindingSource, false, false);

        UnbindBindingSource(this.projectBindingSource, false, true);

 

 

(Updated 11/1/2007)