extra characters in textbox when using shortcut keys

G

Guest

In VS 2003 and VS 2005 beta 2 I am trying to write a simple program. It has
a datagrid and a textbox along with a menubar. There is a command in the
menu bar which is "Run Query" and has the shortcut key of Ctrl + R If I am
typing in my textbox and hit Ctrl + R an extra r character will show up in
the textbox. I decided to then try this in VS 2005 and the same thing
happens. If I include the following,

Private Sub txtQuery_KeyDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtQuery.KeyDown
If e.KeyCode = Keys.R And e.Control = True Then e.SuppressKeyPress =
True
End Sub

The the r character does not show up providing that an exception does not
occur. In VS 2005 I am taking advantage of the Application Events so that I
do not have to put Try Catch blocks everywhere.

Private Sub MyApplication_UnhandledException(ByVal sender As Object,
ByVal e As
Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs)
Handles Me.UnhandledException
MsgBox(My.Resources.Error_GeneralMessage & vbNewLine &
e.Exception.Message.ToString, MsgBoxStyle.Critical,
My.Application.Info.ProductName)
e.ExitApplication = False
End Sub

If an exception is thrown, when I press Ctrl + R and extra r will show up in
the textbox. Does anyone know how I could get around this problem? I could
tie Ctrl + R into the Keydown event or KeyPress of the textbox, but I would
like it to work even if it does not have focus. I had a previous post with
regards to global exceptions causing problems during this process and
discovered it was the 3rd party control that I was using that caused the
errors. Using the Microsoft controls fixed these issues but I keep
experencing what I mentioned above. Any help I would greatly appreciate
it... Thanks...
 
G

Guest

Hi Nick,

I created one small application with one text box and one menubar with
shortcut key as Ctrl+R. In my application the extra "r" character is not
appearing in text at the time of pressing shorcut.
 
K

Kevin Yu [MSFT]

Thanks for Ajay's quick response.

Hi Nick,

I also created a same app on my machine. It works fine without showing an
extra 'r' in the text box.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top