Textbox disabled with a huge string

后端 未结 2 2043
失恋的感觉
失恋的感觉 2020-12-20 03:07

I\'m having a issue with a textbox when it\'s typed a huge string.

In my case, the textbox is used to write email addresses, and it doesn\'t have a limi

相关标签:
2条回答
  • 2020-12-20 03:32

    Try to set the Multiline property to True and increase the height of the textbox

    0 讨论(0)
  • 2020-12-20 03:36

    This is a known limitation in the Windows EDIT control, the native control that's wrapped by the TextBox class. I know the limitation is present in Windows 7 SP1 and Windows 8, earlier versions almost surely have it too.

    You'll exercise this limit once you display more than about 5000 characters in a single-line TextBox. Give or take, it is based on the total width in pixels of the displayed text. So you can fit a lot more when you use a smaller font or have a lot more i than W characters. Afaik, you'll trip the limit when the width exceeds 32767 pixels, a number that pops up in a few places in the USER32 api and dates back to Windows versions <= 3 which were 16-bit. Keeping EDIT compatible across major releases for 30 years was a major effort.

    This limit does not get put to the test very often, stuffing that many characters in a single-line text box isn't practical. There is no reasonable way the user can do anything useful with that much text in so little space. Cannot possibly read it, reliable editing is certainly out of the question.

    Do consider a more practical and user-friendly UI, the limitation simply stops being an issue. Use Multiline = true or just display a place-holder string that uses ellipsis.

    0 讨论(0)
提交回复
热议问题