Keypress event for combobox (and others)

0
0

Howdy,

In winforms i use to block the insert of letters to allow only number, like this for combobox’s and textbox’s:
In WiseJ how can I achieve that? I tried the same code but it’s not working, the form is with KeyPreview=true

 

Private Sub cb_quota_KeyPress(sender As Object, e As KeyPressEventArgs) Handles cb_quota.KeyPress
If e.KeyChar = Chr(Keys.Back) Then
Exit Sub
End If
If Not Char.IsDigit(e.KeyChar) Then
e.Handled = True
End If
End Sub

  • You must to post comments
0
0

Yes it works fine, the widgets all use the same infrastructure. I just tried this:

 private void Window1_Load(object sender, EventArgs e)
 {
     this.comboBox1.AddClientEventListener("keypress", "var e = arguments[0]; if ('0123456789'.indexOf(e.getKeyIdentifier()) === -1 && e.getKeyIdentifier() != 'Backspace')e.stop();");
 }

You can also attach javascript events in the designer.

  • You must to post comments
0
0

Thanks Luca,

Tried this for combobox but no result, should it work for combo’s?

cb_quota.AddClientEventListener(“keypress”, ”var e = arguments[0];if (‘0123456789’.indexOf(e.getKeyIdentifier()) === -1 && e.getKeyIdentifier() != ‘Backspace’)e.stop();”)

  • You must to post comments
0
0

You can’t control the user browser keyboard from the server. You need to attach a javascript event.

 

See: https://wisej.com/support/question/input-type-problem

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.