Connecting Tech Pros Worldwide Forums | Help | Site Map

compact framework form keydown event???

Newbie
 
Join Date: Jun 2009
Posts: 12
#1: Jun 18 '09
Hi All,
I am trying to get Form keydown event in compact framework 3.5 but event is not triggering.
I have just one form form1.
Expand|Select|Wrap|Line Numbers
  1. Public Class Form1
  2.     Dim oBinarySave As New Binary_Serialization
  3.     Dim FlagFormKeyDown As Boolean = False
  4.     Dim uicounter1 As UInt16 = 0
  5.     Dim uicounter2 As UInt16 = 0
  6.  
  7.     Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyDown
  8.         If Not FlagFormKeyDown Then
  9.             FlagFormKeyDown = True
  10.             uicounter1 += 1
  11.             Label1.Text = uicounter1
  12.         End If
  13.  
  14.     End Sub
  15.  
  16.     Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Panel1.KeyUp
  17.         uicounter2 += 1
  18.         Label2.Text = uicounter2
  19.         FlagFormKeyDown = False
  20.     End Sub
  21. End Class
  22.  
whts problem...?

Frinavale's Avatar
Site Moderator
 
Join Date: Oct 2006
Location: The Great White North
Posts: 5,137
#2: Jun 18 '09

re: compact framework form keydown event???


Are you sure it's not triggering?
Did you use the debugger to determine if the application steps into the method that handles the KeyDown Event?

It may be that you aren't refreshing the display and so the Label you're using to display the uicounter1 variable isn't updating.

-Frinny
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#3: Jun 18 '09

re: compact framework form keydown event???


If anything other then the form has the focus, it won't generate key up/down events.
Newbie
 
Join Date: Jun 2009
Posts: 12
#4: Jun 20 '09

re: compact framework form keydown event???


Thanks,
for your guidance. the application is for wince. and i dont have win ce emulator installed on my system thats why i cannot go in debug mode.
Secondly form is selected and all keyboards events goes to form.
I have got solution. The solution is that there is a Key Preview property of forum that is set to false by default. if we turn it to true. then events will trigger and now triggering.
Plater's Avatar
Moderator
 
Join Date: Apr 2007
Location: New England
Posts: 7,161
#5: Jun 22 '09

re: compact framework form keydown event???


If your device has active sync, you can debug through that.
I always wondered about that property, sometimes it works for people, other times it doesn't.
Reply


Similar .NET Framework bytes