Is there a way to enumerate (and suspend) all binding sources on a form? RRS feed

  • Question

  • Hi,

    I'm working with Windows Forms bound to custom business objects which support the IEditableObject interface.

    When the users clicks "Save", I'm using a BackgroundWorker to handle the database updates on a separate thread. To prevent cross-thread exceptions from databound controls, I'd like to call SuspendBinding() on all the BindingSources on the form (of which there are now 15-20 to cope with various drop-down lists, etc.)

    Is there a way I can programatically enumerate every binding-source on the form (short of recursively scanning all the forms child controls and looking for DataBindings?) in order to suspend/resume them all?




    Thursday, November 23, 2006 3:27 PM


  • Hi Dylan.

    Please take a look at the BindingContext enumerable property of the Form class, I think it supports what you are looking for:


    Specifically, you will need something that resembles this code snippet:

            foreach (BindingManagerBase Mgr in this.BindingContext)







    Monday, November 27, 2006 3:41 AM