Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6363025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:59:00+00:00 2026-05-24T23:59:00+00:00

If I turn off automatic updating of a binding data source by setting DataSourceUpdateMode

  • 0

If I turn off automatic updating of a binding data source by setting DataSourceUpdateMode = Never and then use a button to update the whole lot (using binding.WriteValue), a problem occurs – Namely, only the first bound control’s data source is updated. All other controls are reset back to the original values.

This is because when the current object changes (as happens after the above WriteValue), if ControlUpdateMode = OnPropertyChange, then all the other controls re-read in the value from the data source.

What is the standard way of avoiding this issue?

One way is to derive a class from BindingSource and add a WriteAllValues method.
This method does the following:

(1) For each Binding, save the ControlUpdateMode

(2) For each Binding, set ControlUpdateMode = Never

(3) For each Binding, call the WriteValue Method

(4) For each Binding, reset ControlUpdateMode to the saved value

(5) For each Binding, if ControlUpdateMode = OnPropertyChange, call the ReadValue method.

Can you see any issues with doing this?

If working with your own classes, would implementing IEditableObject resolve the issue?

In another control I’m working on, I implement my own binding. The way I get around the issue in that is with the following code. (I’ve put in the bare minimum, I hope you can follow it!):

Private Shared ControlDoingExplicitUpdate As MyCustomControl = Nothing

Private Sub UpdateDataSourceFromControl(ByVal item As Object, ByVal propertyName As String, ByVal value As Object)
  Dim p As PropertyDescriptor = Me.props(propertyName)
  Try
    ControlDoingExplicitUpdate = Me
    p.SetValue(item, value)
  Catch ex As Exception
    Throw
  Finally
    ControlDoingExplicitUpdate = Nothing
  End Try
End Sub

Private Sub DataBindingSource_CurrentItemChanged(ByVal sender As Object, ByVal e As System.EventArgs)
  If (ControlDoingExplicitUpdate IsNot Nothing) AndAlso (ControlDoingExplicitUpdate IsNot Me) Then Exit Sub
  Me.UpdateControlFromDataSource() 'Uses ReadValue
End Sub

So, when UpdateDataSourceFromControl is called, all the CurrentItemChanged events will be called for all other controls in the same BindingSource. However, because ControlDoingExplicitUpdate is set, they will not re-read in the value from the data source unless they happen to be the control that did the updating.
ControlDoingExplicitUpdate is set to Nothing after all these events have completed, so that normal service resumes.

I hope you can follow this, and – again – I ask, can you see any issues with this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T23:59:02+00:00Added an answer on May 24, 2026 at 11:59 pm

    I have had similar requirements for a form. In my case I only wanted the databinding for all the form’s controls to occur when I clicked the form’s Save button.

    The best solution I found was to set each binding’s DataSourceUpdateMode to OnValidation then set the containing form’s AutoValidate property to Disable. This prevents binding as you change focus between controls on the form. Then in the Click event for my Save button, I manually validate my form’s input and, if it is OK, call the form’s ValidateChildren method to trigger the binding.

    This method also has the advantage of giving you full control over how you validate your input. WinForms do not include a good way to do this by default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a possibility to turn off the automatic enclosing of all written content
Can any one tell me how to turn off automatic outlining in Visual Studio?
Is there a way turn off touch events that use a UIView class? I'm
Is there a way to turn off the automatic selection of the first row
How can I turn off Django's automatic HTML escaping, when I write into model's
I want to turn off dumping out the contents of the entire data model
How can we turn automatic brightness off in android?
Anyone know how to turn off code folding in visual studio 2008? Some of
How can I turn off certificate revocation for a WCF service's client? The client
Is it possible to turn off all HTML formatting in Visual Studio 2008? It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.