Keyo
Keyo

Reputation: 119

RichTextbox MaxLength too small

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?

Upvotes: 2

Views: 10144

Answers (4)

user8953270
user8953270

Reputation: 1

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.

Upvotes: 0

Kamran Khan
Kamran Khan

Reputation: 9986

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!

Upvotes: 0

Foxfire
Foxfire

Reputation: 5765

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

Upvotes: 1

Nelson Rothermel
Nelson Rothermel

Reputation: 9776

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.

Upvotes: 1

Related Questions