RichTextbox MaxLength too small

和自甴很熟 提交于 2019-12-24 07:35:31

问题


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?


回答1:


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.




回答2:


The default for RichTextBox.MaxLength is 2GB, so with a 4MB file this is not going to be your problem.




回答3:


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!




回答4:


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.



来源:https://stackoverflow.com/questions/2739811/richtextbox-maxlength-too-small

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!