How to put a specific character in specific place in textbox?
for example, i have to put "/" into fifth pace in textbox with max lenght of 7 characters.
So, when user starts writing something "/" is in fifth position and he can't remove it.
Textbox
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

vivek kulkarni132 reputationPosted Jul 22, 2009, 5:25 AM EDT
Please use maskededittextbox.
Thank you,
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jul 22, 2009, 11:16 AM EDT
strPhone = objPhoneFormat.AddMask("99999/99", strPhone);
public string AddMask(object ImaskFormat, object IActText)
{
int maskLen;
int strCount;
string maskDelimiter;
strCount = 0;
string strResult = string.Empty;
try
{
for (maskLen = 0; maskLen < ImaskFormat.ToString().Length; maskLen++)
{
maskDelimiter = ImaskFormat.ToString().Substring(maskLen, 1).ToUpper();
if (maskDelimiter != "9" & maskDelimiter != "X" & maskDelimiter != "A")
{
strResult += maskDelimiter;
}
else
{
strResult += IActText.ToString().Substring(strCount, 1);
strCount += 1;
}
}
}
catch
{
strResult = IActText.ToString();
}
finally
{
}
return strResult;
}
Hrvoje51 reputationPosted Jul 22, 2009, 10:22 PM EDT