Reputation: 2857
By default, the value of MaxLength
is 32676
. How can I set this value to no limit, or infinite?
Upvotes: 0
Views: 8903
Reputation: 24232
You can set it to 0
. From the documentation on MaxLength:
Windows NT 4.0, Windows 2000, Windows 2000 Professional, Windows 2000 Server, Windows 2000 Advanced Server, Windows XP Home Edition, Windows XP Professional x64 Edition, Windows Server 2003 Platform Note: If the MaxLength property is set to 0, the maximum number of characters the user can enter is 2147483646 or an amount based on available memory, whichever is smaller.
Windows Millennium Edition Platform Note: If the MaxLength property is set to 0, the maximum number of characters the user can enter is 32,766 or an amount based on available memory, whichever is smaller.
So while infinite isn't possible, slightly more than 2 billion characters ought to be enough.
Upvotes: 3
Reputation: 116307
(Assuming a WinForms TextBox) Since MaxLength is Int32, you will only be able to bring it to Int32.MaxValue
.
That's quite a lot actually (2,147,483,647). Do you really need it to be infinite? Then you are better off using a custom control (which you may very well derive from one of the existing ones, off course).
Upvotes: 1