private void NewDoc() { FrmDoc fd = new FrmDoc(); fd.MdiParent = this; fd.Text = "文档" + _Num; fd.WindowState = FormWindowState.Maximized; fd.Show(); fd.Activate(); _Num++; }
private void TSCbBoxFontName_Click_1(object sender, EventArgs e) { try { FontDialog fd = new FontDialog(); if (fd.ShowDialog() == DialogResult.OK) { FrmDoc f = (FrmDoc)this.ActiveMdiChild; f.rTBDoc.SelectionFont = fd.Font; } } catch { } }
public void replacertbs(string FindString, string repstring, bool b) { doc = (FrmDoc)this.ActiveMdiChild; if ((FindString != "") == (doc.rTBDoc.SelectedText != "")) { doc.rTBDoc.SelectedText = repstring; } else { if (FindPostion >= doc.rTBDoc.Text.Length)//已查到文本底部 { MessageBox.Show("已搜索完毕。", "提示", MessageBoxButtons.OK); FindPostion = 0; return; }//下边语句进行查找,返回找到的位置,返回-1,表示未找到,参数1是要找的字符串 //参数2是查找的开始位置,参数3是查找的一些选项,如大小写是否匹配,查找方向等 if (b) { FindPostion = doc.rTBDoc.Find(FindString, FindPostion, RichTextBoxFinds.None); } else { FindPostion = doc.rTBDoc.Find(FindString, FindPostion, RichTextBoxFinds.MatchCase); } if (FindPostion == -1)//如果未找到 { MessageBox.Show("搜索完毕。", "提示", MessageBoxButtons.OK); FindPostion = 0;//下次查找的开始位置 } else//已找到 { doc.rTBDoc.Focus(); doc.rTBDoc.SelectedText = repstring;//主窗体成为注视窗口 FindPostion += FindString.Length; }//下次查找的开始位置在此次找到字符串之后 } }
public void FindRichTextBoxString(string FindString, bool b) { FindPostion = 0; try { doc = (FrmDoc)this.ActiveMdiChild; if (FindPostion >= doc.rTBDoc.Text.Length)//已查到文本底部 { MessageBox.Show("已搜索完毕。", "提示", MessageBoxButtons.OK); FindPostion = 0; return; }//下边语句进行查找,返回找到的位置,返回-1,表示未找到,参数1是要找的字符串 //参数2是查找的开始位置,参数3是查找的一些选项,如大小写是否匹配,查找方向等 if (b) { FindPostion = doc.rTBDoc.Find(FindString, FindPostion, RichTextBoxFinds.None); } else { FindPostion = doc.rTBDoc.Find(FindString, FindPostion, RichTextBoxFinds.MatchCase); } if (FindPostion == -1)//如果未找到 { MessageBox.Show("已到文本底部,再次查找将从文本开始处查找", "提示", MessageBoxButtons.OK); FindPostion = 0; //下次查找的开始位置 // return false; } else//已找到 { doc.rTBDoc.Focus();//主窗体成为注视窗口 FindPostion += FindString.Length; }//下次查找的开始位置在此次找到字符串之后 } catch { } }