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 の値を返します。 この例では、指定した検索文字列の大文字と小文字を一致させる検索のオプションも指定します。 この例では、このメソッドが、richTextBox1という名前のRichTextBoxを含むFormのクラスに配置されていることを前提としています。 この例は、検索テキストの最初のインスタンスが見つかり、テキストの他のインスタンスを見つけたら、"次を検索" 型の操作を実行するときに使用できます。
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 メソッドが呼び出されたときに検索を実行する方法を指定できます。 この列挙体の 1 つ以上の値を組み合わせて、 Find メソッドを呼び出すときに複数の検索オプションを指定できます。