Hello,
I have this form with a menustrip, a combobox and a textbox. I want to use the combination of keys ALT+D in both the combobox and the textbox to insert a special character when typing. This works fine with the combobox but when I am typing in the textbox, after I press the ALT+D combination the menustrip is selected and I can't continue typing anything until I select the textbox again.
Here is the code I am using:
Can anyone help me solve this because I have no idea how. Also, I wouldn't like to disable the Alt key for the menustrip because users are used to this in windows.
Thank you.
I have this form with a menustrip, a combobox and a textbox. I want to use the combination of keys ALT+D in both the combobox and the textbox to insert a special character when typing. This works fine with the combobox but when I am typing in the textbox, after I press the ALT+D combination the menustrip is selected and I can't continue typing anything until I select the textbox again.
Here is the code I am using:
Code:
Public Class Form1
Private Sub ComboBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyDown
If e.Alt And e.KeyCode = 68 Then
ComboBox1.SelectedText = "Ø"
End If
End Sub
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
If e.Alt And e.KeyCode = 68 Then
TextBox1.SelectedText = "Ø"
End If
End Sub
End Class
Thank you.