Results 1 to 2 of 2

Thread: [RESOLVED] e.KeyChar in CF

  1. #1

    Thread Starter
    Addicted Member scsfdev's Avatar
    Join Date
    Feb 2008
    Location
    Singapore
    Posts
    224

    Resolved [RESOLVED] e.KeyChar in CF

    Hi all,

    I want to know how can I achieve below VB.Net [Windows] code in CF environment?

    Thanks.

    VB.Net Code:
    1. Private Sub txtRemark2_KeyPress(ByVal sender As System.Object, _
    2.     ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRemark2.KeyPress
    3.         If IsNumeric(e.KeyChar) = True Then
    4.         Else
    5.             ' This is just an example. In actual, I will change the value to correspond key value.
    6.             e.KeyChar = "5"c
    7.         End If
    8.     End Sub


    In Windows application, e.KeyChar is not read only so I can assign value back to it and it will reflect on textbox.
    But in CF, it is read only that means I can't assign value to it.
    Although in Object Browser, it said its "Gets" and "Sets", i can't assign value to it.
    (Why the object browser shows us incorrect definition?????)

    When I assign value, it will highlight and said this is 'Read Only'
    Anybody can help me???
    Thanks.
    I'm using VS 2005 & 2008 & 2010 with SQL Server 2005 Express.

    My hobby beside programming: http://dslrstranger.wordpress.com

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: e.KeyChar in CF

    Hi,
    you will probably have to do something like
    If IsNumeric(e.KeyChar) Then
    Else
    txtRemark2.Text = txtRemark2.Text.Substring(0, txtRemark2.TextLength) & "5"
    txtRemark2.SelectionStart = txtRemark2.TextLength
    e.Handled = True
    End If
    in the above example

    That should do it
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width