RichTextBoxFinds 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定如何在 RichTextBox 控件中执行文本搜索。
此枚举支持其成员值的按位组合。
public enum class RichTextBoxFinds
[System.Flags]
public enum RichTextBoxFinds
[<System.Flags>]
type RichTextBoxFinds =
Public Enum RichTextBoxFinds
- 继承
- 属性
字段
| 名称 | 值 | 说明 |
|---|---|---|
| None | 0 | 查找搜索文本的所有实例,无论在搜索中找到的实例是否为全字。 |
| WholeWord | 2 | 仅查找全字搜索文本的实例。 |
| MatchCase | 4 | 仅找到具有确切大小写的搜索文本实例。 |
| NoHighlight | 8 | 如果未找到搜索文本,则不应突出显示。 |
| Reverse | 16 | 搜索从控件文档的末尾开始,搜索到文档的开头。 |
示例
以下示例搜索传递到方法的文本参数中的搜索字符串的第一个实例的整个内容 RichTextBox 。 搜索起始位置由方法的 start 参数指定。 如果在搜索字符串中找到 RichTextBox,该方法将返回找到的文本的第一个字符的索引位置,并突出显示找到的文本;否则,它将返回值 -1。 该示例还指定搜索中的选项,以匹配指定搜索字符串的事例。 该示例假定此方法放置在包含Form命名RichTextBox的richTextBox1类中。 在找到搜索文本的第一个实例以查找其他文本实例后,可以在执行“查找下一步”类型操作时使用此示例。
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;
}
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;
}
Public Function FindMyText(text As String, start As Integer) As Integer
' Initialize the return value to false by default.
Dim returnValue As Integer = - 1
' Ensure that a search string has been specified and a valid start point.
If text.Length > 0 And start >= 0 Then
' Obtain the location of the search string in richTextBox1.
Dim indexToText As Integer = richTextBox1.Find(text, start, _
RichTextBoxFinds.MatchCase)
' Determine whether the text was found in richTextBox1.
If indexToText >= 0 Then
returnValue = indexToText
End If
End If
Return returnValue
End Function
注解
应用程序通过调用RichTextBox控件的方法Find查找控件中的RichTextBox文本。 通过此枚举,可以指定在调用方法时 Find 如何执行搜索。 可以合并此枚举中的一个或多个值,以在调用 Find 该方法时指定多个搜索选项。