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

只找出全字拼寫須相符之搜尋文字的執行個體。

範例

下列範例會針對傳遞至 方法之 text 參數之搜尋字串的第一個實例,搜尋 的整個內容 RichTextBox 。 搜尋起始位置是由 方法的 start 參數所指定。 如果在 中找到 RichTextBox 搜尋字串,此方法會傳回找到文字第一個字元的索引位置,並反白顯示找到的文字;否則會傳回 -1 的值。 此範例也會指定搜尋中的選項,以符合指定搜尋字串的大小寫。 此範例假設這個方法放在 包含 RichTextBox 具名 richTextBox1 的 類別 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

備註

應用程式會呼叫 Find 控制項的 RichTextBox 方法, RichTextBox 以找出控制項中的文字。 這個列舉可讓您指定呼叫 方法時 Find 搜尋的執行方式。 您可以結合這個列舉中的一或多個值,以在呼叫 Find 方法時指定多個搜尋選項。

適用於

另請參閱