473,325 Members | 2,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Keydown event

win
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control triggered, the
coding in the keydown of the form does not triggered.

Can anyone help me?
Thanks a lot.
Jan 4 '08 #1
7 1799
On Jan 4, 10:51 am, "win" <a...@aaa.comwrote:
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control triggered, the
coding in the keydown of the form does not triggered.

Can anyone help me?
Thanks a lot.
While your form active, that code must work:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F12 Then
Me.Close()
End If
End Sub
Jan 4 '08 #2
"win" <aa*@aaa.comschrieb
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control
triggered, the coding in the keydown of the form does not triggered.

Set the Form's KeyPreview property to True. (like it was in VB6)
Armin
Jan 4 '08 #3
On Jan 4, 11:51 am, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jan 4, 10:51 am, "win" <a...@aaa.comwrote:
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control triggered, the
coding in the keydown of the form does not triggered.
Can anyone help me?
Thanks a lot.

While your form active, that code must work:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = Keys.F12 Then
Me.Close()
End If
End Sub
Note: When there's nothing on form like buttons, listboxes or others,
this code works. But if there are some other controls placed on form,
i don't know the reason that it doesn't work, maybe focusing problem?
Jan 4 '08 #4
On Jan 4, 11:43 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"win" <a...@aaa.comschrieb
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control
triggered, the coding in the keydown of the form does not triggered.

Set the Form's KeyPreview property to True. (like it was in VB6)

Armin
Hi Armin, yes setting KeyPreview to "true" also replied my question.
Jan 4 '08 #5
win
Thanks all
"kimiraikkonen" <ki*************@gmail.comwrote in message
news:25**********************************@21g2000h sj.googlegroups.com...
On Jan 4, 11:43 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"win" <a...@aaa.comschrieb
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control
triggered, the coding in the keydown of the form does not triggered.
Set the Form's KeyPreview property to True. (like it was in VB6)

Armin

Hi Armin, yes setting KeyPreview to "true" also replied my question.

Jan 4 '08 #6
"win" <aa*@aaa.comschrieb:
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control triggered, the
coding in the keydown of the form does not triggered.
Either set the form's 'KeyPreview' property to 'True' or add a mainmenu
component with a menu item which has the appropriate shortcut.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 4 '08 #7
Win,

As forever about this question I ask another question, why the keydown and
not the keyup, that one gives a lot of information which keys have been
pressed.

Cor

"win" <aa*@aaa.comschreef in bericht
news:Os****************@TK2MSFTNGP02.phx.gbl...
I'm convert a VB6 program to .Net platform.
My program use function key (F12) to close a form.
Now I found that the coding in the keydown event of control triggered, the
coding in the keydown of the form does not triggered.

Can anyone help me?
Thanks a lot.

Jan 4 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: bardo | last post by:
I have a Datagrid that is inside a panel. I want to use the keyDown event to reconize the arrow keys. But I have no luck at all. The problem is that the keydown event won't fire at all, unless I...
4
by: Tony | last post by:
I'm building a simple "breakout" style video-game, and I want keyboard control of the paddle. What I need is for an event handler to respond whenever a key is pressed, regardless of what the...
4
by: Anne | last post by:
hie again, i have 3 textbox and i would like the user to go to the next textbox by pressing the 'ENTER' key. i have tried using this: Private Sub txtRequestor_KeyDown(ByVal sender As...
4
by: ShaneO | last post by:
I would like to handle the KeyUp & KeyDown events in the same event handler but can't find how to determine which event was fired - Private Sub ListBox1_KeyUp(ByVal sender As Object, ByVal e As...
1
by: fripper | last post by:
I have a VB 2005 windows app and I want to recognize keydown events. I have a form key down event handler but it does not get control when a key is depressed. In playing around I found that if I...
0
by: tony | last post by:
Hello!! I have a derived class called StringClassEditor which inherit from UITypeEditor listed below. Now to my question in method EditValue in this class I have this statement lb.KeyDown ...
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
3
by: win | last post by:
when the cursor is in a textbox, only coding in the keydown event of the textbox triggered, the coding in the keydown event of the form does not triggered! Problem: I need to change a VB6 program...
2
by: Tony Johansson | last post by:
Hello! I have created a Control that consist of a label and a textbox.I have called this class ctlLabelTextbox. public partial class ctlLabelTextbox : UserControl { .... } The class that I...
14
by: raylopez99 | last post by:
KeyDown won't work KeyPress fails KeyDown not seen inspired by a poster here:http://tinyurl.com/62d97l I found some interesting stuff, which I reproduce below for newbies like me. The main...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.