RichTextbox MaxLength 太小
我需要在 RichTextBox 中打开一个大约 4MB 的文本文件,但文本的末尾被“修剪”。
如何覆盖 RichTextBox.MaxLength Int32 限制?
I need to open a text file with ~4MB in a RichTextBox, but the end of the text was "trimmed".
How do I override a RichTextBox.MaxLength Int32 limit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不确定 RichTextBox 可以处理多少文本,但我相信 MaxLength 仅适用于用户输入的文本。如果直接设置 .Text,它应该能够超过 MaxLength,除非 MaxLength 已经达到最大值。
I'm not sure how much text RichTextBox can handle, but I believe MaxLength only applies to text the user enters. If you set .Text directly it should be able to go past MaxLength, unless MaxLength is already at the maximum.
RichTextBox.MaxLength 的默认值为 2GB,因此对于 4MB 的文件,这不会成为您的问题。
The default for RichTextBox.MaxLength is 2GB, so with a 4MB file this is not going to be your problem.
除此之外,您可以通过设置文本长度来设置文本限制(最大限制受您的内存限制),例如:
if (textToAdd.Length > richTextBox1.MaxLength)
...加载那么多听起来不太好框中的数据量;您可能会遇到
内存不足
打嗝!这个答案可能会有所帮助。
--编辑--
必须,如果加载,则可以从文件加载块。当用户单击滚动按钮(向上/向下)时,加载该文件块;听起来像一些代码 - 但必须,如果你加载!只是想!
Besides that, you can set the text limit(max limit is limited by your memory) by setting its length, something like:
if (textToAdd.Length > richTextBox1.MaxLength)
...it doesn't sound good loading that much amount of data in the box; you may run into
out of memory
hiccups!This answer may help.
--EDIT--
Must, if you load, then you can load chunks from the file. And as user clicks the scroll button(up/down) load that chunk of the file; sounds like some code - but Must, if you load! Just thinking!
好的,RichTextBox 的最大大小是 2,147,483,647,这需要大量输入,如果您正在考虑复制过去,那么读入数据可能比复制到 RichTextBox 更好。
OK the max size of the RichTextBox is 2,147,483,647 that is a lot of typing, if you are thinking copy past it may better to read in the data as opposed to copying to a RichTextBox.