I have a form that opens with a panel and multiple textboxes displayed that I created via the GUI. Once the user enters the desired information within this panel, a button is click and a new panel appears with the same textboxes displayed as the original. This panel and all of it's textboxes were created via code. As with the original, a button is clicked and another panel appears (identical to the first two). This third panel is created via the same code as the second.
Now the challenge: The original panel has one textbox that has a Sub FuncKeysModule attached to it that allows the user to use the function Key F1 perform a routine. The code looks like this:
Public Sub txbUM_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txbUM.KeyDown If e.KeyValue = Keys.F1 Then FuncKeysModule(e.KeyValue) e.Handled = True End If End Sub Public Sub FuncKeysModule(ByVal value As Keys) 'Check what function key is in a pressed state, and then perform the corresponding action. Select Case value Case Keys.F1 'Add the code for the function key F1 here. MessageBox.Show("F1 pressed") End Select End Sub
The specific textbox is called "txbUM". On the original panel, the F1 key works as it was designed. However when the subsequent panels are created via code, the function key no longer works, even though the textbox name is still "txbUM". The only difference is that this textbox is now within a different panel with a different name.
The question: Would you know how to ensure the Function Key F1 will work in the newly created panel(s)?
To further clarify, the form has a main, primary panel that all of this resides in. That main panel is called "pnlMainPanel". This main panel was designed on the form via the GUI. The smaller panel with the textboxes in it is called "pnlOriginalPanel". Again, this was designed on the form via the GUI. With the button click event, an identical panel is created and is now called "pnlOrderLine" (I hope I haven't confused everyone).
If you have questions, please don't hesitate to ask.
Thanks for your help.