I have created a textbox and can put an infinite number of characters in it, I want to restrict that to only allow the user to type in 250 characters as this is the limit in my database.
I have tried myTextBox.MaxLength = 250
this will still allow the user to type in more than 250 but when I go back in it will only display 250 which means that some data after this amount is lost and the user might not be aware.
I am looking for a way to restrict any more characters from being entered after 250 characters.
CodePudding user response:
The problem here was that I was limiting the size of the string being displayed on my form after I pull the data from the database when I used myTextBox.MaxLength = 250
when loading my form. here I was actually limiting the amount of text being displayed and not the amount of text the user could add.
by adding the code myTextBox.MaxLength = 250
when loading the component it now limits the amount of character I can type in the text box.