richTextBox的字符数限制? [英] richTextBox limit of characters?

查看:481
本文介绍了richTextBox的字符数限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将丰富的文字储存在丰富的文字框中时遇到问题。



我试图读取相当大的文字档到450mb),并把我已经读在一个丰富的文本框。它工作在一个简单的程序,但是当我在一个复杂的程序,我得到一个OutOfMemory异常。需要注意的一点是,当我退出我的简单程序时,我在程序返回0之前得到一个OutOfMemory异常。


$ b



< $ b

这是我的简单程序的代码:

  array< String ^> ^ strArray; 
StreamReader ^ sr;
String ^ dummyStr;
int dummyInt

sr = gcnew StreamReader(C:\\testsize.txt);

while((dummyStr = sr-> ReadLine())!= nullptr)
{
dummyInt ++;
}
sr-> Close();

sr = gcnew StreamReader(C:\\testsize.txt);
strArray = gcnew array< String ^>(dummyInt);
for(int i = 0; i {
strArray [i] = sr-> ReadLine
}
richTextBox1-> Lines = strArray;

我在项目中有一个类似的代码片段,当我做richTextBox1 - > Lines = strArray行。



我已经阅读了丰富的文本框的文档,它说最大限制是64KB的字符,但这是有意义的一半,因为我可以加载文本,但我想程序有一个问题dumping它之后。



任何想法?我一直在试图找到一些自定义控件没有限制,但到目前为止没有成功。

解决方案

大量的文本变成丰富的编辑,这通常会是令人难以置信的慢,以记事本为例,尝试和打开一个2MB的文件。我认为更高级的文本编辑器处理这些是通过一个虚拟控制我知道这些通常与列表控件使用的方式,我会认为与文本框也。它们基本上与您的正常日常控制相同,但没有试图一次渲染文本的大部分,他们有虚拟空间屏幕空间。



至于你的内存不足问题...我很困惑你说的错误发生在你的示例代码的最后一行,当你尝试和转储你的文本到它。你还提到,限制是64KB所以现在假设你的文件是巨大的,你说...有意义,你得到一个错误,你试图转储超过64KB的文本到64KB有限的框。我缺少一些东西?



编辑我重读了一些问题,我看到你现在要求的,所以在简单的程序,错误后一切都加载完成,当程序退出时。



编辑2 现在我知道你在使用什么系统了,我去看看,文档有点比64K限制更复杂。其中首先不是指64 KB,而是64000个字符。另请注意,您可以随意更改此限制。其次,如果你使用SF_TEXT而不是SF_RTF进行流式处理,这个限制没有效果,我想象的是.NET界面背后的情况。


I'm having a problem with storing amazing amounts of text in a rich TextBox.

I'm trying to read a text file fairly big( anywhere from 90mb to 450mb), and put what I've read in a rich textbox. It works in a simple program, but when I do in a complicated program I get an OutOfMemory exception.

One thing to note is that when I exit my simple program, I get an OutOfMemory exception right before the program returns 0.

Here is my simple program's code:

    array<String^>^ strArray;
    StreamReader^ sr;
    String^ dummyStr;
    int dummyInt;

        sr = gcnew StreamReader("C:\\testsize.txt");

        while( (dummyStr = sr->ReadLine() )!= nullptr)
        {
            dummyInt++;
        }
        sr->Close();

        sr = gcnew StreamReader("C:\\testsize.txt");
        strArray = gcnew array<String^>( dummyInt );
        for(int i=0; i < strArray->Length; i++)
        {
            strArray[i] = sr->ReadLine();
        }
        richTextBox1->Lines = strArray;

I have a similar snippet of code in my project, and the exception pops up when I do the richTextBox1->Lines = strArray line.

I have read the documentation of the rich textbox, and it says the max limit is 64KB worth of characters, but that makes sense halfway through, as I can load the text, but I guess the program has a problem dumping it afterwards.

Any ideas? I have been trying to find maybe some custom controls without a limit, but to no success so far.

解决方案

As far as dumping a huge amount of text into a rich edit, this usually is going to be excruciatingly slow, take notepad for example, try and open a 2MB file with it. I think the way more advanced text editors deal with these is by a 'virtual control' I know these are often used with list controls, and I would think with text boxes as well. They basically act/function the same way as your normal everyday control but without trying to render oodles of text at a time, they have virtual space 'off the screen space'.

As far as your out of memory issue... I'm confused you say the error happens at the last line of your sample code when you try and dump your text to it. You also mention that the limit is 64KB so now assuming your file is huge like you say... it makes sense you get an error there you've tried to dump more than 64KB text into a 64KB limited box. Am I missing something?

Edit I reread some of the question I see what you are asking now, so in the simple program you get an error after everything is loaded done, when the program exits. Throw a debug point into your destructors, and see exactly where this error happens.

Edit 2 Now that I know what system you are on, I went and had a look, the documentation is a little more complex than 64K limit. Which first of all isn't referring to 64 KB but rather 64000 characters. Also note that you can change this limit as you please. Secondly if you are streaming with SF_TEXT and not SF_RTF this limit has no effect, which I would imagine is what is going on behind the seen of the .NET interface.

这篇关于richTextBox的字符数限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆