how to make textBox default value, for example 0, in my textBox not available to remove, in other words, do not allow user make textBox empty , but allow to change it, if user removed his value, I want keep my textbox with zero?
One approach would be subscribing to TextChanged
event and assigning default value when it is empty
.
textBox.TextChanged += textBox_TextChanged;
private void currencyTextBox_TextChanged(object sender, EventArgs e)
{
if(string.IsNullOrWhiteSpace(textBox.Text))
{
textBox.Text = "0";
}
}