RichTextbox MaxLength too small

2019-07-29 13:03发布

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?

4条回答
欢心
2楼-- · 2019-07-29 13:22

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.

查看更多
smile是对你的礼貌
3楼-- · 2019-07-29 13:27

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

查看更多
倾城 Initia
4楼-- · 2019-07-29 13:28

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!

查看更多
够拽才男人
5楼-- · 2019-07-29 13:40

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.

查看更多
登录 后发表回答