IncrementalSearch::AppendCharAndSearch Method (Int16)

 

Adds a character to the ISearch pattern and performs a search for the new string.

Namespace:   EnvDTE80
Assembly:  EnvDTE80 (in EnvDTE80.dll)

vsIncrementalSearchResult AppendCharAndSearch(
	short Character
)

Parameters

Character
Type: System::Int16

A short integer that translates to a Unicode character.

AppendCharAndSearch adds a new character to the search pattern (see the Pattern property) and then searches for the new pattern in the current direction.

If a match is found, the editor selection moves to the match and the Found value is returned.

If a match is not found, the selection does not change and the Failed value is returned. New characters may not be appended to a failed search pattern. To make further progress with AppendCharAndSearch, the erroneous character must be removed from the pattern.

Use the AscW() function to provide the Unicode code point for the character.

Sub testIS()
    ' Set variables for text pane.
    Dim tp As EnvDTE80.TextPane2
    tp = CType(DTE.ActiveDocument.ActiveWindow.Object.ActivePane, _
    TextPane2)
    ' Start an incremental search forward from
    ' the current insertion point in the document.
    tp.IncrementalSearch.StartForward()
    ' Add the character "a" to the search pattern.
    tp.IncrementalSearch.AppendCharAndSearch(Asc("a"))
    ' Display the status of the search mode.
    'MsgBox("ISearch status: " & _
    tp.IncrementalSearch.IncrementalSearchModeOn.ToString)
    ' Perform incremental search using the pattern ("a").
    tp.IncrementalSearch.SearchWithLastPattern()
    ' After the search, exit incremental search mode.
    tp.IncrementalSearch.Exit()
End Sub
Return to top
Show: