您的位置:首页 > 编程语言 > C#

关于记事本的“查找下一个”以及“向上向下”,C#.net的一个简单实现

2011-04-20 22:40 651 查看
然后纠缠了一个晚上,终于把高手们不怎么感兴趣的记事本“查找下一个”给实现了。

本人对是c++转过来学.net 的,理解方式可能还保留了C++的习惯,各位将就啦。



private void button1_Click(object sender, EventArgs e)

{

//fm1.textBox1 .Text =textBox1 .Text ;



fm1.richTextBox1.Focus();

if (radioButton1.Checked == true)

i = fm1.richTextBox1.Find(textBox1.Text, i + 1, RichTextBoxFinds.MatchCase);

else if (radioButton2.Checked == true)

if (i == 0)

i = 1;

else if (i >= 0)

i = fm1.richTextBox1.Find(textBox1.Text, 0, i - 1, RichTextBoxFinds.Reverse);

else if (i < 0)

i = 0;



}

在msdn中,很容易的找到了这个(当时理所当然的,在开始位置int start那里填上了i,结果发现根本无法继续,进入死循环了,呵呵)



Overload List

NameDescription

Find( array<
, Int32, Int32)
Searches a range of text in a RichTextBox control for the first instance of a character
from a list of characters.

Find(String, Int32, RichTextBoxFinds)Searches the text in a RichTextBox control for a string at a specific location
within the control and with specific options applied to the search.

Find(String, Int32, Int32, RichTextBoxFinds)Searches the text in a RichTextBox control for a string within a range of text
within the control and with specific options applied to the search.



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐