Textbox

zhaozj2021-02-16  63

1. How to limit Textbox only enter numbers (including decimal)?

private void TextBox_KeyPress (object sender, System.Windows.Forms.KeyPressEventArgs e) {TextBox txt = (TextBox) sender; if (e.KeyChar == 8) {return;} if (e.KeyChar == 46 && txt.Text == - 1) {return;}} (e.keychar> 57 || E.keychar <48) {E.handled = true; this.focus ();}}

转载请注明原文地址:https://www.9cbs.com/read-19876.html

New Post(0)