本文整理匯總了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;
}