Below is a piece of code that I modified from some code I found on EE created by Ronald Biemans. It deals with capturing the UP ARROW key and based on whether a listbox is visible, I send the key or I don't. The DON'T SEND was the main thing I was looking for and it works like a charm.
My problem now is that if I use the SendKeys with UP ARROW it locks up VB.NET. If I send a standard character it works fine.
Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
If msg.WParam.ToInt32() = CInt(Keys.Up) Then
If lbAutoComplete.Visible = True Then
' DO NOTHING, IGNORE UP ARROW
Return MyBase.ProcessCmdKey(msg, keyData)
End Function 'ProcessCmdKey
I have also tested the code below that he included also if SendKeys won't work. At least with this my application doesn't lock up, but I have several ideosync.... when I attempt to use it.
1) The UP ARROW does not fire.
2) Any other buttons on the form depress but don't work.
3) The cursor quit blinking.
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Private Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" _
(ByVal wCode As Integer, ByVal wMapType As Integer) As Integer
Private Sub UpArrow()
keybd_event(Keys.Up, MapVirtualKey(Keys.Up, 0), 0, 0) ' Down ARROW UP
keybd_event(Keys.Up, MapVirtualKey(Keys.Up, 0), 2, 0) ' Up ARROW UP
I don't fully understand all of the aspects of the Override code above, but it gave me the action I was looking for in that it ignores the UP ARROW keypress. Please help because it's critical I resolve this so that I can incorporate it into a bunch of forms and complete this project.