I know that it was some time for this publication, but perhaps it would help someone in the future to face the same problem. I struggled with this for several days, but finally figured it out.
if you set CauseViolation to false, then you are not solving the problem, and the data binding stops working.
When you pay attention to SelectedItem on a property like this
combobox.DataBindings.Add("SelectedItem", someObject, "MySelectedItemProperty", false, DataSourceUpdateMode.OnPropertyChanged)
combobox calls the Equals method of the object you are using in the list that is assigned to your DataSource. In my case, I had to rewrite the Equals method in this object. For some stupid reason, combobox calls this method and passes System.DBNull before passing the correct object type for comparison. In this case, a violation occurred in my case and caused a violation, so without dropping the cursor from the drop-down list. Also the weird part was that the program did not stop when an exception was thrown in my Equals method.
As soon as I added this code
if (obj.GetType() != this.GetType()) return false;
to my Equals method, everything worked fine. Hope this helps someone.
source share