- private int currentIndex = 0;
- private string searchKey;
- private bool isFound = false;
- private void button4_Click(object sender, EventArgs e)
- {
- searchKey = textBox2.Text.Trim();
- if (searchKey == "")
- {
- MessageBox.Show("^0^ 搞什么呀?不管您是帅锅还是美女都应该输入要查找的关键字吧?", "^0^^0^^0^", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- currentIndex = richTextBox1.Find(searchKey, currentIndex, RichTextBoxFinds.None);
- if (currentIndex == -1)
- {
- if (isFound)//表示如果曾经找到过
- {
- MessageBox.Show("已经搜索到文件最底部!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show("没有搜索到关于[" + searchKey + "]的任何内容!", "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- currentIndex = 0;//重置索引
- isFound = false; //重置标志位
- }
- else
- {
- this.richTextBox1.Select(currentIndex, searchKey.Length);
- currentIndex += searchKey.Length;
- isFound = true;
- }
- }
亲爱的:被墙域名跳转TG:@qianhenetwork QQ:851617266,可否收藏+评论+分享呢?
文章评论 本文章有个评论