RichTextBoxFinds 列挙型

定義

RichTextBox コントロールで文字列の検索を実行する方法を指定します。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

public enum class RichTextBoxFinds
[System.Flags]
public enum RichTextBoxFinds
[<System.Flags>]
type RichTextBoxFinds = 
Public Enum RichTextBoxFinds
継承
RichTextBoxFinds
属性

フィールド

MatchCase 4

大文字と小文字が正確である検索文字列のインスタンスだけを検索します。

NoHighlight 8

検索文字列は、見つかっても強調表示されません。

None 0

検索で見つかるインスタンスが検索文字列の語句に完全一致であるかどうかにかかわらず、検索文字列に一致するインスタンスをすべて検索します。

Reverse 16

検索はコントロールのドキュメントの末尾から開始され、先頭に向かって実行されます。

WholeWord 2

検索文字列の語句に完全一致するインスタンスだけを検索します。

次の例では、 メソッドの RichTextBox text パラメーターに渡された検索文字列の最初のインスタンスについて、 の内容全体を検索します。 検索の開始位置は、 メソッドの start パラメーターで指定します。 で RichTextBox検索文字列が見つかった場合、 メソッドは、見つかったテキストの最初の文字のインデックス位置を返し、見つかったテキストを強調表示します。それ以外の場合は、-1 の値を返します。 この例では、指定した検索文字列の大文字と小文字を一致させる検索のオプションも指定します。 この例では、このメソッドが、 という名前richTextBox1の を含む のFormクラスにRichTextBox配置されていることを前提としています。 この例は、検索テキストの最初のインスタンスが見つかり、テキストの他のインスタンスを見つけたら、"次の検索" 型操作を実行するときに使用できます。

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 指定できます。

適用対象

こちらもご覧ください