Well,
I do believe this is reciprocatable, but maybe my system is just wacky like this.
NumericUpdown on a form, with a DataSet, TableAdapter, and BindingSource
Bind the Value property of the NumericUpDown to a numeric (integer or float, mine is currently a money type in the DB (decimal interpreted by VS))
Frist, unlike other controls, or should I say unlike the DataGridView, I have to specifically call the BindSource.EndEdit() to get the changes to reflect upon the DataSet.HasChanges() which is fine, I don't mind that one bit, but the process is strange:
Me.ud_WWriteOff.DataBindings.Add(New System.Windows.Forms.Binding("Value", Me.bind_InvWood, "WriteOff", True, DataSourceUpdateMode.OnValidation, 0.0, "C2"))
Me.ud_PWriteOff.DataBindings.Add(New System.Windows.Forms.Binding("Value", Me.bind_InvPlastic, "WriteOff", True, System.Windows.Forms.DataSourceUpdateMode.OnValidation, 0.0, "C2"))
Private Sub UpDown_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles ud_PWriteOff.Validated, ud_WWriteOff.Validated
If Not _closing Then
If sender Is ud_PWriteOff Then
bind_InvPlastic.EndEdit()
Else : bind_InvWood.EndEdit()
End If
UpdateSums(ColumnsToSum.WriteOff)
sp_InfoLab.Text = "Wood: " & bind_InvWood.CurRow.RowState.ToString() & " - Plastic: " & bind_InvPlastic.CurRow.RowState.ToString()
End If
End Sub
Private Sub ud_PWriteOff_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ud_PWriteOff.ValueChanged, ud_WWriteOff.ValueChanged
Dim ud As NumericUpDown = TryCast(sender, NumericUpDown)
If ud.isValid() Then
Console.WriteLine(ud.Name & ": " & ud.Value & " - Table: " & CType(ud.DataBindings(0).DataSource, FlufBindSource).CurRow.As(Of ReconcileDataSet.tbl_InvoicesRow).WriteOff)
End If
End Sub
If you change the NumericUpDown with the arrow keys, the Console prints the change immediately. WHen you exit the control, the OnValidated is called, enforcing the EndEdit(), and listing the current rowstate for the item, which in this situation will be "Modified".
Now, Clear out the changes and try again. This Time, instead of using the Arrow keys to change the value of the UpDown control, simply type in a number and press the "Enter", and then TAB to exit out of the control focus. In this circumstance, upon hitting enter the ValueChanged() event fires, printing the changed value, and when you exit the control the Validated() event first and the similar path as when using the Arrow keys occurs here as well.
The Third time we try this, change the value by typing in a number, but then directly tab out to the next control. The ValueChanged() event triggers, but the OnValidated() event does not.
Any ideas why? (I figure most likely I'll put in an OnLeave() event that does something or other, or perhaps I'll move the BindSource.EndEdit() into the ValueChanged() event, not sure how much that will effect, but I
am still
very curious as to why the Enter key has such an effect upon the update process of the numeric updown. Perhaps all the controls act the same way, *shrug*, it is just an interesting design if it is intentional)
Thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
"Never Trust a computer. Your brain is smarter than any micro-chip."