本文整理汇总了C#中System.Windows.Forms.RichTextBox.Find方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.Find方法的具体用法?C# RichTextBox.Find怎么用?C# RichTextBox.Find使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.Find方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindMyText
public int FindMyText(string searchText, int searchStart, int searchEnd)
{
// Initialize the return value to false by default.
int returnValue = -1;
// Ensure that a search string and a valid starting point are specified.
if (searchText.Length > 0 && searchStart >= 0)
{
// Ensure that a valid ending value is provided.
if (searchEnd > searchStart || searchEnd == -1)
{
// Obtain the location of the search string in richTextBox1.
int indexToText = richTextBox1.Find(searchText, searchStart, searchEnd, RichTextBoxFinds.MatchCase);
// Determine whether the text was found in richTextBox1.
if(indexToText >= 0)
{
// Return the index to the specified search text.
returnValue = indexToText;
}
}
}
return returnValue;
}
示例2: FindMyText
public int FindMyText(string text, int start)
{
// 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 && start >= 0)
{
// Obtain the location of the search string in richTextBox1.
int indexToText = richTextBox1.Find(text, start, RichTextBoxFinds.MatchCase);
// Determine whether the text was found in richTextBox1.
if(indexToText >= 0)
{
returnValue = indexToText;
}
}
return returnValue;
}
示例3: button1_Click
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)
{
// Return the location of the character.
returnValue = indexToText;
}
}
return returnValue;
}
示例4: button1_Click
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show(FindMyText(new char[]{'B','r','a','v','o'}, 5).ToString());
}
public int FindMyText(char[] text, int start)
{
// Initialize the return value to false by default.
int returnValue = -1;
// Ensure that a valid char array has been specified and a valid start point.
if (text.Length > 0 && start >= 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, start);
// Determine whether any of the chars are found in richTextBox1.
if(indexToText >= 0)
{
// Return the location of the character.
returnValue = indexToText;
}
}
return returnValue;
}
示例5: FindMyText
public bool FindMyText(string text)
{
// Initialize the return value to false by default.
bool returnValue = false;
// Ensure a search string has been specified.
if (text.Length > 0)
{
// Obtain the location of the search string in richTextBox1.
int indexToText = richTextBox1.Find(text);
// Determine whether the text was found in richTextBox1.
if(indexToText >= 0)
{
returnValue = true;
}
}
return returnValue;
}
示例6: FindMyText
public bool FindMyText(string text)
{
// Initialize the return value to false by default.
bool returnValue = false;
// Ensure a search string has been specified.
if (text.Length > 0)
{
// Obtain the location of the search string in richTextBox1.
int indexToText = richTextBox1.Find(text, RichTextBoxFinds.MatchCase);
// Determine if the text was found in richTextBox1.
if(indexToText >= 0)
{
returnValue = true;
}
}
return returnValue;
}