Hello,
I am working on a program in which I allow the user to quickly add strings to a textbox by pressing a key combination, such as ALT+S. Inserting the strings and setting the cursor to the right position works fine. Its just that windows makes an annoying beep as if an error was encountered every time I press the key combination. I am using the KeyDown event to handle the keystrokes, and I have tried e.Handled = True - without success. Here's a bit of code to give you the idea:
Thanks for helping out!
Ibby
I am working on a program in which I allow the user to quickly add strings to a textbox by pressing a key combination, such as ALT+S. Inserting the strings and setting the cursor to the right position works fine. Its just that windows makes an annoying beep as if an error was encountered every time I press the key combination. I am using the KeyDown event to handle the keystrokes, and I have tried e.Handled = True - without success. Here's a bit of code to give you the idea:
VB.NET:
Private Sub TextBox1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
Dim CursorPosition As Integer = TextBox1.SelectionStart
If e.Alt And e.KeyCode = Keys.S Then
TextBox1.Text = TextBox1.Text.Insert(CursorPosition, "sin(")
TextBox1.SelectionStart = CursorPosition + 4
End If
' Same kind of If statements continue here.
End Sub
Thanks for helping out!
Ibby