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
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.
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 can’t control the user browser keyboard from the server. You need to attach a javascript event.
Please login first to submit.