Private Sub AccountType_KeyDOWN(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.Return Then
ProcessTabKey(True)
End If
End Sub
Private Sub anytextbox_Enter(sender As Object, e As EventArgs) Handles Twitter.Enter, Email.Enter, PhoneNoOffice.Enter, PhoneNoHome.Enter, PhoneNoMobile.Enter, EName.Enter, AName.Enter, IDCode.Enter, ExpiryDate.Enter, BankAccount.Enter
Dim txt As TextBox = DirectCast(sender, TextBox)
stroldvalue = txt.Text
End Sub
Private Sub anytextbox_KeyDown(sender As Object, e As KeyEventArgs) Handles Twitter.KeyDown, Email.KeyDown, PhoneNoOffice.KeyDown, PhoneNoHome.KeyDown, PhoneNoMobile.KeyDown, EName.KeyDown, AName.KeyDown, IDCode.KeyDown, ExpiryDate.KeyDown, BankAccount.KeyDown
Dim txt As TextBox = DirectCast(sender, TextBox)
If e.KeyCode = Keys.Enter Or e.KeyCode = Keys.Tab Then
If txt.Text <> stroldvalue Then
connectunauth()
cmd = New SqlCommand("Insert into changes values(@id,@txtname,@oldval,@newval)", Variables.UnauthCon)
cmd.Parameters.AddWithValue("@id", CustomerNo.Text)
cmd.Parameters.AddWithValue("@txtname", txt.Name)
cmd.Parameters.AddWithValue("@oldval", stroldvalue)
cmd.Parameters.AddWithValue("@newval", txt.Text)
cmd.ExecuteNonQuery()
UnauthCon.Dispose()
NOCHANGE = True
End If
End If
End Sub
在上面的代码中,我面临以下错误: 进入一个文本框时,该值将保存在stroldvalue中。 在上面更改后按Enter键,form_keydown事件首先触发,它会运行anytextbox_enter事件,导致stroldvalue被下一个文本框值覆盖。然后文本框keydown事件触发。
我尝试了表单的按键事件,但是按键事件没有捕获输入键按下组合框。 我应该怎么做才能在textbox keydown事件之后触发form的keydown。