RichTextBoxFinds 열거형
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
RichTextBox 컨트롤에서 텍스트 검색을 수행하는 방법을 지정합니다.
이 열거형은 멤버 값의 비트 조합을 지원합니다.
public enum class RichTextBoxFinds
[System.Flags]
public enum RichTextBoxFinds
[<System.Flags>]
type RichTextBoxFinds =
Public Enum RichTextBoxFinds
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| None | 0 | 검색에서 찾은 인스턴스가 전체 단어인지 여부에 관계없이 검색 텍스트의 모든 인스턴스를 찾습니다. |
| WholeWord | 2 | 전체 단어인 검색 텍스트의 인스턴스만 찾습니다. |
| MatchCase | 4 | 정확한 대/소문자를 가진 검색 텍스트의 인스턴스만 찾습니다. |
| NoHighlight | 8 | 검색 텍스트(있는 경우)를 강조 표시해서는 안 됩니다. |
| Reverse | 16 | 검색은 컨트롤의 문서 끝에서 시작하여 문서의 시작 부분으로 검색됩니다. |
예제
다음 예제에서는 메서드의 RichTextBox 텍스트 매개 변수에 전달된 검색 문자열의 첫 번째 인스턴스에 대한 전체 내용을 검색합니다. 검색 시작 위치는 메서드의 시작 매개 변수에 의해 지정됩니다. 검색 문자열이 있는 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 할 때 둘 이상의 검색 옵션을 지정할 수 있습니다.