How to input a decimal ex. 1,234.56 in a textbox
tnx
TextBox
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhijit PatilRank #700 · 3.4K reputationPosted Feb 9, 2014, 5:52 PM EST
the textbox have not that type of facility to get only digit.but you can validate the textbox using keypress event of this textbox.
see below code
if(char.IsDigit(e.KeyChar)==false && Convert.ToInt32(e.KeyChar)!=8)
{
MessageBox.Show("Enter Numeric Only");
e.handled=true;
}
it can take only digit ,now we need to validate as per your requirment like if u enter
123456
then it can get value as 1,234.56
for that you can import namespace as System.Globalization;
and write down the following code
Praveen N104 reputationPosted Feb 9, 2014, 5:49 PM EST
Could you please be clear with your question ?
Regards,
Praveen Nelge
Cris Abella6 reputationPosted Feb 10, 2014, 2:54 AM EST
Abhijit PatilRank #700 · 3.4K reputationPosted Feb 10, 2014, 3:27 AM EST