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

  • Home
  • SEARCH
  • 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 95315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:38:20+00:00 2026-05-10T23:38:20+00:00

Bound GetChanges always returns something when bound to a UserControl ‘s property (even on

  • 0

Bound GetChanges always returns something when bound to a UserControl‘s property (even on a simple one)

I have made a UserControl, for some reason unbeknownst to me, when I bound a DataColumn to my control’s property the dataSet1.GetChanges() always return something, even the column bound to my control was not changed.

What’s the possible cause why GetChanges always return something?

Here’s a simple snippet to reproduce the binding/GetChanges problem:


using System;  using System.Data;  using System.Windows.Forms;   namespace BindingBug {      public partial class Form1 : Form     {          DataSet _ds = new DataSet();          void GetData()         {                        var t = new DataTable             {                 TableName = 'beatles',                 Columns =                 {                     {'lastname', typeof(string)},                     {'firstname', typeof(string)},                     {'middlename', typeof(string)}                 }             };               t.Rows.Add('Lennon', 'John', 'Winston');             t.Rows.Add('McCartney', 'James', 'Paul');              _ds.Tables.Add(t);                     }          public string Hey { set; get; }          public Form1()         {             InitializeComponent();              var tLastname = new TextBox { Top = 100 };             var tFirstname = new TextBox { Top = 130 };              this.Controls.Add(tLastname);             this.Controls.Add(tFirstname);              GetData();               tLastname.DataBindings.Add('Text', _ds.Tables['beatles'], 'lastname');             tFirstname.DataBindings.Add('Text', _ds.Tables['beatles'], 'firstname');              // if the following line is commented 2nd:Has Changes == false             this.DataBindings.Add('Hey', _ds.Tables['beatles'], 'middlename');               _ds.AcceptChanges();               MessageBox.Show('1st:Has Changes = ' + _ds.HasChanges().ToString());               var bDetectChanges = new Button { Top = 160, Text = 'Detect Changes' };             bDetectChanges.Click +=                  delegate                  {                     this.BindingContext[_ds.Tables['beatles']].EndCurrentEdit();                     MessageBox.Show('2nd:Has Changes = ' +  (_ds.GetChanges() != null).ToString());                  };              this.Controls.Add(bDetectChanges);          }         } } //namespace BindingBug 
  • 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. 2026-05-10T23:38:21+00:00Added an answer on May 10, 2026 at 11:38 pm

    i was able to solve the problem today, the key thing is to make the BindingContext’s EndCurrentEdit aware if the value really changed. for this, we must implement System.ComponentModel.INotifypropertychanged on our control. i just saw the solution from here: http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.propertychanged.aspx

    hope this can help others implementing their own controls which flag wrong change status on GetChanges()

    public partial class Form1 : Form, System.ComponentModel.INotifyPropertyChanged {     //----------- implements INotifyPropertyChanged -----------       // wish C# has this VB.NET's syntactic sugar     public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged; // implements INotifyPropertyChanged.PropertyChanged       //----------- start of Form1  ----------       DataSet _ds = new DataSet();        void NotifyPropertyChanged(string propertyName)     {         if (PropertyChanged != null)             PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));     }        void GetData()     {          var t = new DataTable         {             TableName = 'beatles',             Columns =             {                 {'lastname', typeof(string)},                 {'firstname', typeof(string)},                 {'middlename', typeof(string)}             }         };           t.Rows.Add('Lennon', 'John', 'Winston');         t.Rows.Add('McCartney', 'James', 'Paul');          t.Columns['middlename'].DefaultValue = '';          _ds.Tables.Add(t);                 }        string _hey = '';     public string Hey      {          set          {             if (value != _hey)             {                 _hey = value;                 NotifyPropertyChanged('Hey');             }         }          get          {                              return _hey;           }      }        public Form1()     {         InitializeComponent();            var tLastname = new TextBox { Top = 100 };         var tFirstname = new TextBox { Top = 130 };          this.Controls.Add(tLastname);         this.Controls.Add(tFirstname);          GetData();            tLastname.DataBindings.Add('Text', _ds.Tables['beatles'], 'lastname');         tFirstname.DataBindings.Add('Text', _ds.Tables['beatles'], 'firstname');          this.DataBindings.Add('Hey', _ds.Tables['beatles'], 'middlename');           _ds.AcceptChanges();             MessageBox.Show('1st:Has Changes = ' + _ds.HasChanges().ToString());          var bDetectChanges = new Button { Top = 160, Text = 'Detect Changes' };         bDetectChanges.Click +=             delegate             {                 this.BindingContext[_ds.Tables['beatles']].EndCurrentEdit();                 MessageBox.Show('2nd:Has Changes = ' + (_ds.GetChanges() != null).ToString());              };          this.Controls.Add(bDetectChanges);      }  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 231k
  • Answers 231k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the following function like this: Image('/path/to/original.image', '1/1', '150*', './thumb.jpg');… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer Check you database schema to see if the field (referenced… May 13, 2026 at 2:13 am
  • Editorial Team
    Editorial Team added an answer I figured out the problem - there was a session… May 13, 2026 at 2:13 am

Related Questions

Bound GetChanges always returns something when bound to a UserControl 's property (even on
I'm duty-bound by policy to use CVS in this certain project, so even though
In a DataGridView bound to a DataView, where cells in a column will contain
I have a ComboBox bound to an ObservableCollection of decimals. What is the correct
I have a GridView bound to an ICollection<UserAnswer> that needs to show two columns:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.