我现在要做一个Windows记事本的查找功能,谁能帮我写一段完整的代码啊,谢谢!
我就只会这几句.刚学的.
private void 查找ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
if (f3 != null)
{
f3.Show();
}
else
{
f3 = new Form3();
f3.Show();
}
}
我就只会这几句.刚学的.
private void 查找ToolStripMenuItem_Click_1(object sender, EventArgs e)
{
if (f3 != null)
{
f3.Show();
}
else
{
f3 = new Form3();
f3.Show();
}
}
//获得Form1窗体的引用
Form1 mainForm = (Form1)this.Owner ;
mainForm.rtxtContent.Focus();
//如果主窗体文本内容不为空,进行查找
if (mainForm.rtxtContent.Text.Length >0) {
if(this.chkUpper.Checked)
FindPlace = mainForm.rtxtContent.Find(txtToSearch.Text,FindPlace,RichTextBoxFinds.MatchCase);
else
FindPlace = mainForm.rtxtContent.Find(txtToSearch.Text,FindPlace,RichTextBoxFinds.None);
if (FindPlace == -1) {
MessageBox.Show ("没有搜索到!");
FindPlace = 0; //没有找到,重置查找位置为文本起点
}
else {
//选中找到的文本,使其明显
mainForm.rtxtContent.Select (FindPlace,txtToSearch.Text.Length );
//找到了,置查找位置为下一个位置
FindPlace = FindPlace + txtToSearch.Text.Length ;
}
}
}