当索引大于Int时,如何在带有C#的RichTextBox中查找和选择文本 [英] How do I find and select Text in a RichTextBox with C# when Index is larger than an Int

查看:133
本文介绍了当索引大于Int时,如何在带有C#的RichTextBox中查找和选择文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在带有C#的RichTextBox中找到并选择一个Text的第一个匹配项,然后选择Text的相同部分的所有其他发现.我知道只要索引不超出Integer Range,就很容易做到.但是,如果这样做怎么办? RichTextBox.Find()和RichTextBox.Select()函数仅支持Integers.现在,我的文本文件在41 KB到150 KB之间更大.对于使用内置函数进行查找和选择的整数,绝对很小.
我该怎么办?有人为此有现成的函数调用吗?
除了在搜索中内置的RichTextBox函数外,什么都没有找到,这些函数仅对小于等于32 KB的文件有效.我是编码方面的新手,我不知道如何在不使用整数的情况下构建自己的函数来查找和搜索RTB,但要花很长时间.这些功能似乎没有重载:(

我目前使用int16,否则会出现类型不匹配的异常.
我在使用VS 2008的Net 2上.在我看来,整数只能携带32768个字符.我想将整个搜索字符串保存在int16中,但到目前为止只能存储一个字符.
我究竟做错了什么?现在,我更改为int32,并且似乎可以编译.

解决方案

一个整数为您提供0到2,147,483,647的范围,对于150 Kb的文件来说应该足够了. /blockquote>

嗯.
int是32位值,范围为-2147483648至2147483647
如果您的富文本格式超过2GB,那么您就遇到了问题-对于初学者来说,用户将永远无法阅读全部内容...


I would like to find and select the first occurrence of a Text in a RichTextBox with C# and then select all the other finds of the same portion of Text. I know that''s simple to do as long the index doesn''t outrun the Integer Range. But what to do if it does? The functions RichTextBox.Find() and RichTextBox.Select() support only Integers. Now my Text Files are quite a bit larger between 41 KB and 150 KB. The Integer is definitely to small for finding and selecting with the inbuilt functions.
What would I do instead? Does someone have a ready function call for this?
Found nothing else than the inbuilt RichTextBox functions on my search which are only valid for files smaller and equal 32 KB. I am a novice in coding and I have no idea how I could build my own functions for finding and searching a RTB without using an Integer but a long. There seem to be no overloads for these functions :(

I currently use an int16 otherwise I get an exception of type mismatch.
I''m on Net 2 with VS 2008. At me the Integer carries only 32768 characters. I want to save the whole search string in the int16 but can store only one char so far.
What am I doing wrong? Now I changed to int32 and it seems to compile.

解决方案

An integer gives you a range of 0 to 2,147,483,647, which should be plenty for a 150 Kb file.


Um.
int is a 32bit value, with a range of -2147483648 to 2147483647
If your rich text exceeds 2GB in size, then you have a problem - and that''s that the user will will never read it all, for starters...


这篇关于当索引大于Int时,如何在带有C#的RichTextBox中查找和选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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