IncrementalSearch.AppendCharAndSearch Method

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

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

Syntax

'Declaration
Function AppendCharAndSearch ( _
    Character As Short _
) As vsIncrementalSearchResult
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
vsIncrementalSearchResult AppendCharAndSearch(
    short Character
)
abstract AppendCharAndSearch : 
        Character:int16 -> vsIncrementalSearchResult
function AppendCharAndSearch(
    Character : short
) : vsIncrementalSearchResult

Parameters

  • Character
    Type: System.Int16

    A short integer that translates to a Unicode character.

Return Value

Type: EnvDTE80.vsIncrementalSearchResult
A vsIncrementalSearchResult enumeration.

Remarks

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.

Examples

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

.NET Framework Security

See Also

Reference

IncrementalSearch Interface

EnvDTE80 Namespace

Other Resources

How to: Search for Text Incrementally

How to: Search a Document Incrementally