|
-
Jul 20th, 2004, 11:12 PM
#1
Thread Starter
Lively Member
key press event
when someone pushes f12 an action takes place. how to do it?
-
Jul 20th, 2004, 11:28 PM
#2
Sleep mode
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
-
Jul 20th, 2004, 11:29 PM
#3
Sleep mode
Set form's KeyPreview property in the Properties Explorer to True .
-
Jul 21st, 2004, 12:05 AM
#4
Thread Starter
Lively Member
-
Jul 21st, 2004, 12:09 AM
#5
Thread Starter
Lively Member
might it be mecause the combo box is selected?
-
Jul 21st, 2004, 12:10 AM
#6
Sleep mode
Originally posted by Synth3t1c
not workin
What do you mean not working ? Do you mean you want to set up a wide-system hotkey or what ?
It's working here .
-
Jul 21st, 2004, 12:13 AM
#7
Sleep mode
Originally posted by Synth3t1c
might it be mecause the combo box is selected?
Even if the focus was in another control , it should trigger the event . I've just tested it .
-
Jul 21st, 2004, 12:17 AM
#8
VB Code:
'syn maybe you forgot to put this.
KeyPreview = True
-
Jul 21st, 2004, 02:31 AM
#9
Fanatic Member
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.
-
Jul 21st, 2004, 04:05 AM
#10
Sleep mode
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.
Are you sure you set the form's KeyPreview property in the Properties Explorer to True ?
-
Jul 21st, 2004, 04:16 AM
#11
Fanatic Member
-
Jul 21st, 2004, 04:21 AM
#12
-
Jul 21st, 2004, 04:28 AM
#13
Fanatic Member
yep. it works. but it won't with the dropdownstyle of combobox1 is set to dropdown. works with the dropdownlist style.
-
Jul 21st, 2004, 06:10 AM
#14
Hyperactive Member
Damned B.M. !
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?
Live long and prosper (Mr. Spock)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|