There are 4 textbox fields. You need to create some method to assign the textbox.Text=0 an empty field. If you write everything through if else , you get a whole mountain of code. Ugly.

  • WinForms? Use NumericUpDown to enter numbers instead of TextBox . - Alexander Petrov

1 answer 1

You can through the event handler:

 private void textBox1_Validated(object sender, EventArgs e) { if (((TextBox)sender).Text == "") { ((TextBox)sender).Text = "0"; } } 

Sign it on all boxes.

Took from here: https://stackoverflow.com/questions/17902882/how-to-enter-a-default-value-when-a-textbox-is-empty