when someone pushes f12 an action takes place. how to do it?
Printable View
when someone pushes f12 an action takes place. how to do it?
Use KeyDown or KeyUp event .
VB Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If e.KeyData = Keys.F12 Then MessageBox.Show("You just pressed F12") End If End Sub
Set form's KeyPreview property in the Properties Explorer to True .
not workin
might it be mecause the combo box is selected?
What do you mean not working ? Do you mean you want to set up a wide-system hotkey or what ?Quote:
Originally posted by Synth3t1c
not workin
It's working here .
Even if the focus was in another control , it should trigger the event . I've just tested it .Quote:
Originally posted by Synth3t1c
might it be mecause the combo box is selected?
VB Code:
'syn maybe you forgot to put this. KeyPreview = True
hello mate. not in combo. i don't know about upper than 2k2 but i don't get the keydown event of the form if the focus is in the combo. :)
Are you sure you set the form's KeyPreview property in the Properties Explorer to True ?Quote:
Originally posted by brown monkey
hello mate. not in combo. i don't know about upper than 2k2 but i don't get the keydown event of the form if the focus is in the combo. :)
yep
Try this . ;)
yep. it works. but it won't with the dropdownstyle of combobox1 is set to dropdown. works with the dropdownlist style. ;)
Damned B.M. !:p
Once again you are right!:)
I use Vs.Net 2003 but I have the same behaviour.
I have a combo in DropDownStyle and...
VB Code:
Private Sub FrmRientri_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown If MessageBox.Show(Me.CmbNumeroDocRientro.DropDownStyle.ToString & " " & " I'm in KeyDown. Do you want to change in DropDown", "", MessageBoxButtons.YesNo) = DialogResult.Yes Then Me.CmbNumeroDocRientro.DropDownStyle = ComboBoxStyle.DropDown End If End Sub
as you can see my procedure show a message box when keydown event is fired. It remind me that is placed in keydown event and ask me if I want to change the style of combo. After two or three rounds I decided to change the style and..... from that moment my event was not more fired. It seems a bug, isn't it? :confused: