RichTextBoxFinds 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定文字搜尋如何在 RichTextBox 控件中執行。
此列舉支援其成員值的位元組合。
public enum class RichTextBoxFinds
[System.Flags]
public enum RichTextBoxFinds
[<System.Flags>]
type RichTextBoxFinds =
Public Enum RichTextBoxFinds
- 繼承
- 屬性
欄位
| 名稱 | 值 | 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 方法時指定多個搜尋選項。