PDA

Click to See Complete Forum and Search --> : [RESOLVED] e.KeyChar in CF


scsfdev
Jun 17th, 2009, 08:38 PM
Hi all,

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

Thanks.

Private Sub txtRemark2_KeyPress(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtRemark2.KeyPress
If IsNumeric(e.KeyChar) = True Then
Else
' This is just an example. In actual, I will change the value to correspond key value.
e.KeyChar = "5"c
End If
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?????) :mad:

When I assign value, it will highlight and said this is 'Read Only' :(
Anybody can help me???
Thanks.

petevick
Jun 18th, 2009, 03:03 AM
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