textbox
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.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question.
HrvojePosted Jul 23, 2009, 2:22 AM
I tried to use maskeedittextbox but it doesn't work. Instead of "/" I get "."
Niradhip ChakrabortyPosted Jul 22, 2009, 3:16 PM
Try this:
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;
}
vivek kulkarniPosted Jul 22, 2009, 9:25 AM
Hi,
Please use maskededittextbox.
Thank you,