How to insert hyphen “-” after 2 digits automatically in TextBox?
问题 I have one TextBox for user to input number. When user input to the TextBox then the format should be like this 01-22-34-40-33 I want to insert "-" after 2 digits in the TextChanged event handler. I do something like this but no work: if(txtRandomThirdTypeSales.Text.Length == 2) { txtRandomThirdTypeSales.Text += "-"; } else if (txtRandomThirdTypeSales.Text.Length == 5) { txtRandomThirdTypeSales.Text += "-"; } else if (txtRandomThirdTypeSales.Text.Length == 8) { txtRandomThirdTypeSales.Text +=