I have a winform where I have a textbox that will take upto 14 numbers. Now if user enters less that 14 i have to populate the rest of the fields with 0s. Eg. if a user 10 numbers the i have to include 4 more 0’s to to make it 14.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Change the
MaxLengthproperty of the text box to 14. After you get theTextproperty, use, thePadLeft, orPadRightmethods on theStringclass.Example
Results
You might also want to consider using the
MaskedTextBoxclass.