compact framework form keydown event???

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • plowgrammer2010
    New Member
    • Jun 2009
    • 12

    compact framework form keydown event???

    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.
    Code:
    Public Class Form1
        Dim oBinarySave As New Binary_Serialization
        Dim FlagFormKeyDown As Boolean = False
        Dim uicounter1 As UInt16 = 0
        Dim uicounter2 As UInt16 = 0
    
        Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyDown
            If Not FlagFormKeyDown Then
                FlagFormKeyDown = True
                uicounter1 += 1
                Label1.Text = uicounter1
            End If
    
        End Sub
    
        Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Panel1.KeyUp
            uicounter2 += 1
            Label2.Text = uicounter2
            FlagFormKeyDown = False
        End Sub
    End Class
    whts problem...?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    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

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      If anything other then the form has the focus, it won't generate key up/down events.

      Comment

      • plowgrammer2010
        New Member
        • Jun 2009
        • 12

        #4
        I have Got Solution.

        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.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          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.

          Comment

          Working...