Im developing a form that has five textboxes that I bind to a DataTable in a DataSet.
If I change a value of one of the textboxes on the form I expect the Rowstate property for the DataTable the textbox is bound to tobe change to Modified, but that isnt happening. It still indicates that the RowState is Unmodified. Though if I check the value of the column in my DataTable it has the value that I keyed into the textbox (using a messagebox behind a button).
I tried adding some additional logic to force an EndCurrentEdit when I change the value of the textbox, but the RowState still says Unmodified.
Any ideas on why the Rowstate of the DataTable doesnt change to Modified when changing the value in the textbox?
Code:
Private Sub BindEvent()
Try
Me.txtEventNbr.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventID"))
Me.txtAccidentLocation.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "LocationDesc"))
Me.txtAccidentDate.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventDate"))
Me.txtAccidentTime.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventTime"))
Me.txtAccidentDesc.DataBindings.Add(New Windows.Forms.Binding("text", dsSafety.Tables("Event"), "EventDesc"))
Catch ex As Exception
MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
If I change a value of one of the textboxes on the form I expect the Rowstate property for the DataTable the textbox is bound to tobe change to Modified, but that isnt happening. It still indicates that the RowState is Unmodified. Though if I check the value of the column in my DataTable it has the value that I keyed into the textbox (using a messagebox behind a button).
I tried adding some additional logic to force an EndCurrentEdit when I change the value of the textbox, but the RowState still says Unmodified.
Code:
Private Sub txtAccidentLocation_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAccidentLocation.LostFocus
Try
Me.BindingContext(dsSafety).EndCurrentEdit()
Catch ex As Exception
MessageBox.Show(ex.Message & vbCrLf & vbCrLf & ex.StackTrace, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Any ideas on why the Rowstate of the DataTable doesnt change to Modified when changing the value in the textbox?