关于用c#做的记事本的一些问题!!!!!!!!!!!!!!!!!!!! string s;s.IndexOf(?);用这个函数,可以处理,然后大概用TextBox的Select??();一个函数就可以搞定了,我前不久才做过,文本查找. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 之前写了一个查找下一个的函数,搂主可以直接调用:private int FindNext(string text, bool bMatchCase, bool bReverse){ if (text == null) return -1; this.richTextBox1.Focus(); RichTextBoxFinds findOptions = RichTextBoxFinds.None; int start = this.richTextBox1.SelectionStart; int end = start; if (bReverse) { start = 0; end = this.richTextBox1.SelectionStart; findOptions |= RichTextBoxFinds.Reverse; } else { start += this.richTextBox1.SelectionLength; end = this.richTextBox1.TextLength; this.richTextBox1.SelectionStart = start; } this.richTextBox1.SelectionLength = 0; if (bMatchCase) { findOptions |= RichTextBoxFinds.MatchCase; } return this.richTextBox1.Find(text, start, end, findOptions);}text-将要被查找的文本;bMatchCase-是否区分大小写;bReverse-是否反向查找 自动换行直接使用this.richTextBox1.WordWrap = true或者false就可以实现了 用richTextBox写记事本吧,很方便,微软都帮你想好了,好多都封装好了,连赊销返回都给你了。Undo(),Redo(); 我用的就是richTextBox 就是出现这个错误//查找 private void menuItemFind_Click(object sender, System.EventArgs e) { new Find(txtResult).Show(); } //查找下一个 private void menuItemFindNext_Click(object sender, System.EventArgs e) { new Replace(txtResult).Show(); }出现的错误是:找不到类型或者命名空间名称“Find”(是否缺少using指令或程序集引用) 找不到类型或者命名空间名称“Replace”(是否缺少using指令或程序集引用) private void menuItemFind_Click(object sender, System.EventArgs e) { (new Find(txtResult)).Show(); } //查找下一个 private void menuItemFindNext_Click(object sender, System.EventArgs e) { (new Replace(txtResult)).Show(); } 晕,我8楼的代码仅仅是修正你在7楼贴出的代码,但我并不知道find和replace两个窗口类是怎么实现的,所以就没有再多说find和replace两个窗口类,内部的查找和替换方法,见我在2楼贴出的代码,你可以调用的 晕,我8楼的代码仅仅是修正你在7楼贴出的代码,但我并不知道你的find和replace这两个窗口类是怎么实现的,所以就没有再多说 find和replace两个窗口类,内部的查找和替换方法,见我在2楼贴出的代码,你可以调用的 不用,new优先级比.要高,,可以不加括号…………查找、查找下一个都调用同一个方法 FindString()public class Notepad{ private string p_find; ... private void FindString() { if (p_find == null || p_find.Length == 0) { // 在这打开一个对话框获得一个要查找的字符串 p_find = ...... if (p_find == null || p_find.Length == 0) return; } textBox1.SelectionStart = textBox1.Text.IndexOf(p_find, textBox1.SelectionStart); textBox1.SelectionLength = p_find.Length; }} 搂主可以下载下面我专门针对文本编辑器软件写的查找和替换功能代码:http://download.csdn.net/source/894891该功能已经做得很完善,可以参考 这里做个一个记事本(带原代码),可以参考一下http://www.popuni.com/article.asp?id=96还是比较简单的 请教 ComboBox 的问题 TabControl控件的分页可以消隐吗? 请教CSDN管理员,在博客中如何插入截图 [急]父控件Size小于子控件时,子控件如何在父控件之上叠加完整显示 能不能在不断网的情况下改IP? 高手请进 征求 C#界面方案! 请问怎样在服务器端调用客户端用c#做的WINDOWS服务?? 我要将网页用抓图软件抓成图片,但是网页很长,超出了屏幕范围,怎么才能得到一张完整的图片呢? 请问在C#中怎样实现TOOLBOX的功能?? c#调用存储过程每次都需要指定参数名称,有什么 方法直接传参数吗? 水晶报表子报表如何绑定数据源
private int FindNext(string text, bool bMatchCase, bool bReverse)
{
if (text == null) return -1; this.richTextBox1.Focus(); RichTextBoxFinds findOptions = RichTextBoxFinds.None; int start = this.richTextBox1.SelectionStart;
int end = start; if (bReverse)
{
start = 0;
end = this.richTextBox1.SelectionStart;
findOptions |= RichTextBoxFinds.Reverse;
}
else
{
start += this.richTextBox1.SelectionLength;
end = this.richTextBox1.TextLength;
this.richTextBox1.SelectionStart = start;
}
this.richTextBox1.SelectionLength = 0; if (bMatchCase)
{
findOptions |= RichTextBoxFinds.MatchCase;
}
return this.richTextBox1.Find(text, start, end, findOptions);
}text-将要被查找的文本;bMatchCase-是否区分大小写;bReverse-是否反向查找
想好了,好多都封装好了,连赊销返回都给你了。
Undo(),Redo();
//查找
private void menuItemFind_Click(object sender, System.EventArgs e)
{
new Find(txtResult).Show();
} //查找下一个
private void menuItemFindNext_Click(object sender, System.EventArgs e)
{
new Replace(txtResult).Show();
}出现的错误是:找不到类型或者命名空间名称“Find”(是否缺少using指令或程序集引用)
找不到类型或者命名空间名称“Replace”(是否缺少using指令或程序集引用)
private void menuItemFind_Click(object sender, System.EventArgs e)
{
(new Find(txtResult)).Show();
} //查找下一个
private void menuItemFindNext_Click(object sender, System.EventArgs e)
{
(new Replace(txtResult)).Show();
}
{
private string p_find;
...
private void FindString()
{
if (p_find == null || p_find.Length == 0)
{
// 在这打开一个对话框获得一个要查找的字符串
p_find = ......
if (p_find == null || p_find.Length == 0)
return;
}
textBox1.SelectionStart = textBox1.Text.IndexOf(p_find, textBox1.SelectionStart);
textBox1.SelectionLength = p_find.Length;
}
}
http://download.csdn.net/source/894891
该功能已经做得很完善,可以参考
http://www.popuni.com/article.asp?id=96
还是比较简单的