2

Here's the simplest of scenarios. I have a Form with a few TextBoxes and a BindingSource, bound to a DataSet instance, and the TextBoxes bound to the BindingSource. Entering text in these TextBoxes doesn't raise CurrentItemChanged event on my BindingSource; not even when I change focus to another textbox. It only fires when I move to another record, which is what one would expect from CurrentChanged. According to MSDN:

The CurrentItemChanged event is raised in response to all of the circumstances that raise the CurrentChanged event. Additionally, CurrentItemChanged is also fired whenever the value of one of the properties of Current is changed.

Please note that I don't want to call EndEdit() because that would commit my changes.

EDIT

Here's my binding code. Now I have added OnPropertyChanged too, without any luck.

Me.bsCatItems.DataMember = "catalog_items"
Me.bsCatItems.DataSource = Me.DsInventory
Me.bsItems.DataSource = Me.bsCatItems
Me.bsItems.DataMember = "FK_CatalogItems_Items"
Me.TextBox1.DataBindings.Add(New System.Windows.Forms.Binding("Text", Me.bsItems, "consignment_count", True, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged))
dotNET
  • 33,414
  • 24
  • 162
  • 251

2 Answers2

1

You must implement the INotifyPropertyChanged interface to enable the CurrentItemChanged event to be raised - the binding source will automatically subscribe to the PropertyChanged event.

To see an example of how the INotifyPropertyChanged can be implemented see for example this link

Community
  • 1
  • 1
Zrethreal
  • 317
  • 4
  • 15
-1

I'm not sure how this works in winforms but in wpf you can set the updatesourcetrigger of the binding to property-changed. If this is set, every time you type something into the textbox, the propertychanged-event will be fired.

I am pretty sure that there's an equal mechanism in winforms.

Tomtom
  • 9,087
  • 7
  • 52
  • 95
  • Since the question mentions that the event is not raised "even when I change focus to another textbox", the property change mode will not make a difference. There is an equivalent mechanism in WinForms, but it won't help with this question. – hurcane Aug 15 '22 at 14:22