关于制作象word中的查找、替换菜单功能? 你每次查找事件被觸發的時候讓richtextbox強制獲得焦點不行嘛? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 明灭由心,怎样强制获得richtextBox.Focus ()吗?这样不行,我心太乱,能否说的具体点? 我用的是两个窗体主窗体private void butCz_Click(object sender, System.EventArgs e) { findpro(); } private void findpro() { Cz dlgCz= new Cz(); dlgCz.ShowDialog(); dlgCz.Focus (); dlgCz.findString =findStr; // Determine the state of the DialogResult property for the form. if (dlgCz.DialogResult == DialogResult.OK) { this.richTextBox1 .Focus (); findStr=dlgCz.findString.Trim () ; int str=this.richTextBox1 .SelectionStart; //MessageBox.Show (findStr); if(this.richTextBox1 .SelectionLength >0)//如果已经找到第一个,下一个从后面的字符开始 str++; int result=this.richTextBox1 .Text .IndexOf(findStr,str); if(result>-1) { this.richTextBox1 .SelectionStart =result; this.richTextBox1 .SelectionLength =findStr.Length ; } else { MessageBox.Show (this,"找不到\""+findStr+"\"","编辑器",MessageBoxButtons.OK); } findpro(); } else { dlgCz.Close (); } }查找窗体:public Cz() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); ff=new Form1(); this.textBox1 .Text =ff.findStr; if (this.textBox1 .Text !="") this.butQd.Enabled =true; else this.butQd.Enabled =false; // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // }有一个findString属性public string findString { get { s=this.textBox1 .Text ; return s; } set { value=value.Trim (); s=value; } } 请问,这种算法,怎么写? C#在主界面中创建了两个线程,如何在主界面的按钮按下时关闭线程1 (求助!急!在线等)在C# 2005/2008 中 如何验证一个XML文件符合一个Schema(XSD)呢 serialport收到数据后再继续发,怎么处理? 为什么我自己定义的控件不能显示ToolTip? c#怎么调用window的messenger服务??? 水晶报表的问题,急~~~ 可以保存imagelist里的图标吗? 救救我吧,一把年纪了 在程序里怎么设定文本的颜色 C#应用程序能在WIN98下运行吗? 在C#中如何获取datetime中的time部分
主窗体
private void butCz_Click(object sender, System.EventArgs e)
{
findpro();
} private void findpro()
{
Cz dlgCz= new Cz();
dlgCz.ShowDialog();
dlgCz.Focus ();
dlgCz.findString =findStr;
// Determine the state of the DialogResult property for the form.
if (dlgCz.DialogResult == DialogResult.OK)
{
this.richTextBox1 .Focus ();
findStr=dlgCz.findString.Trim () ;
int str=this.richTextBox1 .SelectionStart;
//MessageBox.Show (findStr);
if(this.richTextBox1 .SelectionLength >0)//如果已经找到第一个,下一个从后面的字符开始
str++;
int result=this.richTextBox1 .Text .IndexOf(findStr,str);
if(result>-1)
{
this.richTextBox1 .SelectionStart =result;
this.richTextBox1 .SelectionLength =findStr.Length ;
}
else
{
MessageBox.Show (this,"找不到\""+findStr+"\"","编辑器",MessageBoxButtons.OK);
}
findpro();
}
else
{
dlgCz.Close ();
} }查找窗体:
public Cz()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
ff=new Form1();
this.textBox1 .Text =ff.findStr;
if (this.textBox1 .Text !="")
this.butQd.Enabled =true;
else
this.butQd.Enabled =false; //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}有一个findString属性
public string findString
{
get
{
s=this.textBox1 .Text ;
return s;
}
set
{
value=value.Trim ();
s=value;
}
}