469,343 Members | 5,316 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

keydown event won't fire

2
Hello.
I'm writing a windows mobile 2003 project for smartphone in vb.net. Using vs2003 compact framework 1.0. In most attempts on my forms I cannot get the keydown event to fire. I'm basically trying to check and uncheck checkboxes using the number keys. Here is a typical sub I'm using:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectExCombo_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  2.  
  3.         If (e.KeyCode = System.Windows.Forms.Keys.Up) Then
  4.             If CheckBox1.Focused Then
  5.                 Panel1.BackColor = color.white
  6.                 Panel2.BackColor = Color.Blue
  7.                 CheckBox9.Focus()
  8.                 GoTo handled
  9.             ElseIf CheckBox9.Focused = True Then
  10.                 Panel1.BackColor = Color.Blue
  11.                 Panel2.BackColor = color.white
  12.                 CheckBox1.Focus()
  13.                 GoTo handled
  14.             End If
  15.         End If
  16.  
  17.         If (e.KeyCode = System.Windows.Forms.Keys.D1) Then
  18.             If CheckBox1.Focused Then
  19.                 If CheckBox1.CheckState = CheckState.Unchecked Then
  20.                     CheckBox1.CheckState = CheckState.Checked
  21.                 ElseIf CheckBox1.CheckState = CheckState.Checked Then
  22.                     CheckBox1.CheckState = CheckState.Unchecked
  23.                     GoTo handled
  24.                 End If
  25.             ElseIf CheckBox9.Focused Then
  26.                 If CheckBox9.CheckState = CheckState.Unchecked Then
  27.                     CheckBox9.CheckState = CheckState.Checked
  28.                 ElseIf CheckBox9.CheckState = CheckState.Checked Then
  29.                     CheckBox9.CheckState = CheckState.Unchecked
  30.                     GoTo handled
  31.                 End If
  32.             End If
  33.         End If
  34.  
Any guidance would be greatly appreciated.
ershn
May 30 '07 #1
2 3864
RedSon
5,000 Expert 4TB
Hello.
I'm writing a windows mobile 2003 project for smartphone in vb.net. Using vs2003 compact framework 1.0. In most attempts on my forms I cannot get the keydown event to fire. I'm basically trying to check and uncheck checkboxes using the number keys. Here is a typical sub I'm using:

Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectExCombo_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
  2.  
  3.         If (e.KeyCode = System.Windows.Forms.Keys.Up) Then
  4.             If CheckBox1.Focused Then
  5.                 Panel1.BackColor = color.white
  6.                 Panel2.BackColor = Color.Blue
  7.                 CheckBox9.Focus()
  8.                 GoTo handled
  9.             ElseIf CheckBox9.Focused = True Then
  10.                 Panel1.BackColor = Color.Blue
  11.                 Panel2.BackColor = color.white
  12.                 CheckBox1.Focus()
  13.                 GoTo handled
  14.             End If
  15.         End If
  16.  
  17.         If (e.KeyCode = System.Windows.Forms.Keys.D1) Then
  18.             If CheckBox1.Focused Then
  19.                 If CheckBox1.CheckState = CheckState.Unchecked Then
  20.                     CheckBox1.CheckState = CheckState.Checked
  21.                 ElseIf CheckBox1.CheckState = CheckState.Checked Then
  22.                     CheckBox1.CheckState = CheckState.Unchecked
  23.                     GoTo handled
  24.                 End If
  25.             ElseIf CheckBox9.Focused Then
  26.                 If CheckBox9.CheckState = CheckState.Unchecked Then
  27.                     CheckBox9.CheckState = CheckState.Checked
  28.                 ElseIf CheckBox9.CheckState = CheckState.Checked Then
  29.                     CheckBox9.CheckState = CheckState.Unchecked
  30.                     GoTo handled
  31.                 End If
  32.             End If
  33.         End If
  34.  
Any guidance would be greatly appreciated.
ershn
I dont know anything about VB but I do know a bit about WM programming. The way that all windows OSs work is by sending your application messages. I assume that in VB KeyEventArgs is similar to the wParams and lParams that are sent in a C/C++ application. I would think that in order to be in line with the Microsoft framework you would want a sub that is like
Expand|Select|Wrap|Line Numbers
  1.  Private Sub HandleExCombo_Message(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs)
Then you can look at e and sender and figure out what message you need to handle in a large case or if...then chain.

What other information can you get from the e object?
May 30 '07 #2
ershn
2
Thank you for your reply.
I haven't been able to find any info that allows me to quantify or control e other than passing it as a generic event argument. What is strange is I have written this app for wm5 and it works fine. Also strange is that, while the app does not respond to the down arrow, it does respond to the up arrow key by tabbing throught the checkbox controls in one of the panels. The arrow keys are causing an event to fire but not the sub I have written by hand.
May 30 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Mike M | last post: by
3 posts views Thread by Frank T. Clark | last post: by
3 posts views Thread by bardo | last post: by
2 posts views Thread by Sam Miller | last post: by
5 posts views Thread by ApexData | last post: by
5 posts views Thread by T | last post: by
14 posts views Thread by raylopez99 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.