473,395 Members | 1,653 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,395 software developers and data experts.

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 4018
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

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

Similar topics

4
by: Mike M | last post by:
I am trying to detect the keydown of the arrow keys in a custom control that I am writing. As far as I can tell, pressing the arrow keys does not fire the KeyDown event at all. It behaves just...
3
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
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...
2
by: Sam Miller | last post by:
Hi, I have a button event that won't fire. I left it on Friday and it worked fine. I came back in on Monday and it won't fire. I tried putting another button and just putting a...
0
by: Peter | last post by:
I have a VB6 program which can receive Keydown events on an ActiveX control. The ActiveX control can't fire keydown events so I put a picturebox below the ActiveX control. I write codes in...
2
by: Phil Galey | last post by:
I have a Panel control docked on all sides on a form and the panel control contains a PictureBox. I'm using the KeyDown event of the form to respond to the and keys for resizing the image and the...
5
by: ApexData | last post by:
This follows a previous post, when I was trying to capture a key pressed during the immediate opening of a form (ie in the first 3-secs before processing any of the code that followed it. It was...
5
by: T | last post by:
Hi, How do I fire the KeyDown event in Managed VC++? I am getting a compile error saying "event does not have a raise method". Please help. regards, T
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.