Conditions

How to limit the character of a TextBox?

private void mds_Click(object sender, RoutedEventArgs e)
{
   If (iText.Text Character?? >= 12 character)
   {
       MessageBos.Show("Wrong Entry");
   }
   
}
Whing Dela CruzAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nishant joshiConnect With a Mentor Technology Development ConsultantCommented:
private void mds_Click(object sender, RoutedEventArgs e)
{
   If (iText.Text.Length() >= 12 character)
   {
       MessageBox.Show("Wrong Entry");
   }
    
}

Open in new window


Regards,
nishant
0
 
NavneetSoftware EngineerCommented:
Hi!

You can set MaxLength propery of textbox
<TextBox MaxLength="12 />


Thanks!
0
 
Whing Dela CruzAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.