想实现写字板的查找功能,窗口间的调用什么都实现的,就是在点了查找后,父窗体的richtextbox查找的字符串没有被颜色显示出来,只有在关闭了查找子窗体后,才显示,请问有什么办法,this.richTextBox1.Select(na, str.Length);//改变richTextBox值中查找的字体颜色 richTextBox1.SelectionBackColor = Color.Blue;//设置选中后的颜色 richTextBox1.SelectionColor=Color.White;这个是找到的一种方法,可是要实现查找下一个,请问这么消除前一个符合条件的字符串,继而显示下一个字符串呢,
frdlg.Show(this); // 代替 frdlg.ShowDialog();
一楼说的很对,FindReplaceDialog就是你的查找窗口名。只是用show(this)来代替你的以前的展示窗口的方式。
int i =0;
private void 查找ToolStripMenuItem_Click(object sender, EventArgs e)
{
fd.MyPing+=new find.PING(fd_MyPing);//关联委托
fd.Show(this);
}
void fd_MyPing(string str) //委托的处理事件
{ int an = richTextBox1.Find(str, i, RichTextBoxFinds.MatchCase);
if (an >0)
{
this.richTextBox1.Select(an, str.Length);
i = an + str.Length;
}
else
{
MessageBox.Show("没有查找到相符的字符串");
}
}
下面是子窗体find的代码public delegate void PING(string str);//定义委托
public event PING MyPing;private void button1_Click(object sender, EventArgs e)
{
this.MyPing(this.textBox1.Text);
}