}
}
在 RichTextBox 的内容内搜索文本:
重载列表
在 RichTextBox 控件的文本中搜索字符列表中某个字符的第一个实例
[C#] public int Find(char[]);
示例
[Visual Basic, C#, C++] 下面的示例在 RichTextBox 的内容中搜索在 text 参数中传递到方法的字符。如果在 RichTextBox 中找到了 text 数组的内容,则该方法返回所找到值的索引;否则,它将返回 -1。该示例假定此方法位于 Form 的类中,该窗体包含一个名为 richTextBox1 的 RichTextBox 控件和一个连接到该示例中定义的单击事件处理方法的 Button 控件(名为 button1)。
[C#]
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(FindMyText(new char[]{'D','e','l','t','a'}).ToString());
}
public int FindMyText(char[] text)
{
// Initialize the return value to false by default.
int returnValue = -1;
// Ensure that a search string has been specified and a valid start point.
if (text.Length > 0)
{
// Obtain the location of the first character found in the control
// that matches any of the characters in the char array.
int indexToText = richTextBox1.Find(text);
// Determine whether the text was found in richTextBox1.
if(indexToText >= 0)
{
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29694-11.html
按现有利率算放银行一年死期也就200块钱吧
感觉是美国品牌评选