I've reviewed dozens of options/solutions on this and I just can't get it to work.
Simply put, I have a VB.Net Winform that has a textbox where a user can manually type in text or they can use a USB connected barcode scanner (that simulates a keyboard) to capture a UPC.
What I'm trying to do is get the barcode input to get entered into the textbox regardless of which control has the current focus.
I have set the KeyPreview property of the form to True.
I then added some code to the frmMain_Keypress event as follows:
If Me.txtSearch.Focused = False Then
Change the code in your KeyPress event to:
If Me.txtSearch.Focused = False Then txtSearch.Focus() txtSearch.Text = e.KeyChar.ToString txtSearch.SelectionStart = txtSearch.Text.Length e.Handled = True End If
That way you capture the first key that comes in.