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 6891311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:23:39+00:00 2026-05-27T06:23:39+00:00

I have controls which are not updating their bound object’s respective properties until focus

  • 0

I have controls which are not updating their bound object’s respective properties until focus is lost. There are similar questions with accepted answers referencing DataSourceUpdateMode.OnPropertyChange being declared, which I do, yet the behavior persists. Here’s an example implementation. I’ll try to be thorough, yet concise. The MyConfig class is accessed through a property in a Singleton class I call Configuration.

[Serializable]
public class MyConfig : INotifyPropertyChanged
{
    public enum MyEnum
    {
        Foo,
        Bar
    }

    public MyConfig()
    {
        MyProperty = MyEnum.Foo;
    }

    private MyEnum _MyProperty;
    public MyEnum MyProperty
    {
        get { return _MyProperty; }
        set { if (value != _MyProperty) { _MyProperty = value; OnPropertyChanged("MyProperty"); } }
    }

    [field: NonSerialized]
    public event PropertyChangedEventHandler PropertyChanged;

    private void OnPropertyChanged(string propertyName)
    {
        if (string.IsNullOrEmpty(propertyName))
            throw new ArgumentNullException(propertyName);
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

public partial class ConfigForm : Form
{
    public ConfigForm()
    {
        InitializeComponent();
        MyComboBox.Items.AddRange(Enum.GetNames(typeof(MyConfig.MyEnum)));
    }

    private void ConfigForm_Load(object sender, EventArgs e)
    {
        MyComboBox.DataSource = Enum.GetValues(typeof(MyConfig.MyEnum));
        MyComboBox.DataBindings.Add("SelectedItem", Configuration.Instance.MyConfig, "MyProperty", false, DataSourceUpdateMode.OnPropertyChanged);
    }
}

I’m not sure, given the following brief implementation, what I could be overlooking to ensure immediate property changes. I can change, in this case from Foo to Bar in the ComboBox, but unless I remove focus from the ComboBox, nothing changes. Does anyone have any ideas?

  • 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-27T06:23:39+00:00Added an answer on May 27, 2026 at 6:23 am

    The WinForms ComboBox is wonky with regards to OnPropertyChanged. Here’s some code from an old project that I used to get OnPropertyChanged working the way I expect for the SelectedItem property. This works for my specific instance, but I usually struggle to get this scenario working sometimes. Good luck!

    /// <summary>
    /// A modification of the standard <see cref="ComboBox"/> in which a data binding
    /// on the SelectedItem property with the update mode set to DataSourceUpdateMode.OnPropertyChanged
    /// actually updates when a selection is made in the combobox.
    /// </summary>
    public class BindableComboBox : ComboBox
    {
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.ComboBox.SelectionChangeCommitted"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnSelectionChangeCommitted(EventArgs e)
        {
            base.OnSelectionChangeCommitted(e);
    
            var bindings = this.DataBindings
                .Cast<Binding>()
                .Where(x => 
                    x.PropertyName == "SelectedItem" && 
                    x.DataSourceUpdateMode == DataSourceUpdateMode.OnPropertyChanged);
            foreach (var binding in bindings)
            {
                // Force the binding to update from the new SelectedItem
                binding.WriteValue();
    
                // Force the Textbox to update from the binding
                binding.ReadValue();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some dynamically created inputs which are not server-side controls. I want to
I am using standard windows forms controls under C#. I have two controls which
I have several similar user controls which display listviews of respectively different data entities.
I have a container of custom controls each of which have 2 controls in
I have some controls on the page which are Invisible on page load. But
I have a datalist control which some controls(ex: button) are in it. I want
I have a form which users can add controls to and when they right
I have a small application which embeds webbrowser controls. In that application I have
I have a WPF Window which has a among other controls hosts a Frame.
I have a page on which I must load controls dynamically based on the

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.