I have a number of databound textboxs, a textbox variable, a measure button, and a save button on a form.
the textbox variable allows auto incrementing of the textboxes after the measure button is pushed and a value is read. I use a doubleclick function on the textboxes also to allow the user to implement a measure function.
relevant code:
Private Sub btn_Measure_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_HA_Measure.Click
If Not IsNothing(measure_current_textbox) Then
test_measurement(measure_current_textbox)
Else
MessageBox.Show("No angle has been selected, please select an textbox to measure", "Error", MessageBoxButtons.OK)
End If
End Sub
Private Sub tbx_Angle_SingleClick(sender As System.Object, e As System.EventArgs) Handles tbx_HA_F1T1.Click, tbx_HA_F1T2.Click
measure_current_textbox = TryCast(sender, TextBox)
End Sub
Private Sub tbx_Angle_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbx_HA_F1T1.DoubleClick, tbx_HA_F1T2.DoubleClick
If Not IsNothing(measure_current_textbox) Then
test_measurement(measure_current_textbox)
Else
MessageBox.Show("No angle has been selected, please select an textbox to measure", "Error", MessageBoxButtons.OK)
End If
End Sub
Private Sub test_measurement(ByVal sender As Textbox)
measure_current_textbox.Text = FormatNumber(5.0, 4)
End Sub
Private Sub btn_Accept_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Accept.Click
Try
TSLinqSQLDataContext.SubmitChanges()
Me.Close()
Catch ex As Exception
MessageBox.Show(Me, ex.Message, "Database Write Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
So both functions call the test_measurement function, both pass the same variable to it, the variable is valid and has a textbox value, the textbox.text field is updated for both and can be seen on the screen for both, but only the double click function will update the database when the Accept button is pressed? Why does the measure button call fail?
Too weird for me, I have no clue, I need help!