📄 form2.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TextEditor
{
public partial class Form2 : Form
{
public int start;
public RichTextBox s1;
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
string str1;//存放要查找的文本
str1=textBox1.Text ;//获取要查找的文本
start=s1.Find(str1,start,RichTextBoxFinds.MatchCase);//查找下一个
if (start==-1) //如果返回值是-1,表示没有找到
{
MessageBox.Show ("已查找到文档的结尾","查找结束对话框");//显示查找结束对消息框
start=0;//查找位置赋值为0,从头开始查找
}
else//查找到
start=start+str1.Length ;//下一次查找的起始位置
s1.Focus() ;//为richTextBox1设置焦点
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -