windows phone 7 - how can i remove digit dash in wp7 -


i working on phone number box. have made format of (888)888-8888. want operate space. if has given wrong number can edit it.

the problem when try remove last digits right side. stops removing digits after 4 digits end. shows me result (888)888-.

here code number , dashes format.

if (phonebox.text.tostring().length == 1)                 {                      phonebox.text = "(" + phonebox.text.tostring();                     phonebox.select(phonebox.text.length, 0);                  }                  else if (phonebox.text.tostring().length == 4)                 {                      phonebox.text = phonebox.text.tostring() + ")";                     phonebox.select(phonebox.text.length, 0);                  }                  else if (phonebox.text.tostring().length == 8)                 {                      phonebox.text = phonebox.text.tostring() + "-";                     phonebox.select(phonebox.text.length, 0);                  } 

here solution attempted not sure whether work.

else if (phonebox.text.tostring().length == 9)             {                  phonebox.text = phonebox.text.tostring()+"";                 phonebox.select(phonebox.text.length, 0);              } 

i'm not sure approach deleting characters line not deleting dash, it's appending empty string object.

 phonebox.text = phonebox.text.tostring()+""; 

if want delete last character, can this

phonebox.text = phonebox.text.substring(0, phonebox.text.length - 1) 

or, can replace - empty string.

phonebox.text = phonebox.text.replace("-", ""); 

Comments