实施前请参考
TextChanged
KeyPress
private void txtBox_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = (e.KeyChar == '0');
}
要处理文本框文本,您可以尝试的是
private void txtBox_TextChanged(object sender, KeyPressEventArgs e)
{
if (String.IsNullOrEmpty(textbox.Text) || txtmoney.Text == "0")
{
// Do Something
}
}
txtBox.KeyPress += txtBox_KeyPress;
txtBox.TextChanged += txtBox_TextChanged;