c# - textbox formatting -


I need some help with my code.

I need the following format,

12345-1234567-1

Actually I just want to write marks and when If the text length reaches 5 then it should add '-' and then the length of 13, then it should be added '-'

My code is correcting it but when I use backspace / delete So, it always adds '-' to the 6th and the 14th place.

This is my code,

  Private zero nicNo_txt_KeyUp (Object Sender, KeyEventArgs E) (If eCode.ToString ()! = "Back" || E. Kcode.ToString ()! = "Space" || E.Code.ToString ()! = "Delete") {if (NicNo_txt.TextLength == 5 || nicNo_txt.TextLength == 13) nicNo_txt.AppendText ("-" ); }}   

Regards

Did you try the masked textbox in it You can specify a mask for the format you need

Comments