I have a combobox in my form. It contains all these keys: BACKSPACE
F16. For example when the key selected in the combobox is pressed do something. How can I do that?
There's a number of ways I could see this going. One would be to create an object with two attributes: one being the key name string and the other being the key itself. Then bind this to the combo box with the key name string as the displayed item.
Another would be to convert the text of your combobox to the key itself using this function:
Public Function KeyFromString(theKey As String) As Keys Dim kc As KeysConverter = New KeysConverter() Return CType(kc.ConvertFrom(theKey), Keys) End Function
like so in whatever key pressed event you are using:
if e.key = KeyFromString(combobox.text) then 'do work end if