c#: By default text box accepts n number of entries,
I want to restrict the entries to its width
Is there any property in text box through which i can achive this,
c#: By default text box accepts n number of entries,
I want to restrict the entries to its width
Is there any property in text box through which i can achive this,
Assuming WinForms, try this:
You could compute the width of the text to be drawn and if it exceeds the textbox width then return.
HERE you can find a great example.
default it accepts only
32767
of chars.You can set the
MaxLength
property of the textbox in thetextbox property
Hope you are using windows forms
No, to do this you will have to calculate the maximium number of characters they can enter by the text box width manually I'm afraid. You'll also have to take into consideration the font and font size too
I know this question is a bit old but to any one looking this is an expansion of George answer. It works with Ctrl + v, context menu paste and typing from key board.