Partager via


IncrementalSearch.SearchBackward Method

Definition

Searches for the current pattern from the current position to the beginning of the document.

public:
 EnvDTE80::vsIncrementalSearchResult SearchBackward();
public:
 EnvDTE80::vsIncrementalSearchResult SearchBackward();
EnvDTE80::vsIncrementalSearchResult SearchBackward();
[System.Runtime.InteropServices.DispId(11)]
public EnvDTE80.vsIncrementalSearchResult SearchBackward ();
[<System.Runtime.InteropServices.DispId(11)>]
abstract member SearchBackward : unit -> EnvDTE80.vsIncrementalSearchResult
Public Function SearchBackward () As vsIncrementalSearchResult

Returns

A vsIncrementalSearchResult enumeration.

Attributes

Examples

Sub testIS2()  
    ' Before running, open a document in Visual Studio.  
    ' Set variables for text pane.  
    Dim tp As EnvDTE80.TextPane2  
    tp = CType(DTE.ActiveDocument.ActiveWindow.Object.ActivePane, _  
    TextPane2)  
    ' Start an incremental search backward from  
    ' the current insertion point in the document.  
    tp.IncrementalSearch.StartBackward()  
    ' Add the character "a" to the search pattern.  
    tp.IncrementalSearch.AppendCharAndSearch(Asc("a"))  
    ' Display the parent name for IncrementalSearch object.  
    MsgBox("IncrementalSearch parent: " & _  
    tp.IncrementalSearch.DTE.FullName)  
    MsgBox("Search pattern length: " & _  
    tp.IncrementalSearch.Pattern.Length)  
    ' Perform incremental search using the pattern ("a").  
    tp.IncrementalSearch.SearchWithLastPattern()  
    ' After the search, exit incremental search mode.  
    MsgBox("DeleteCharAndBackup")  
    tp.IncrementalSearch.DeleteCharAndBackup()  
    MsgBox("SearchForward")  
    tp.IncrementalSearch.SearchForward()  
    MsgBox("SearchBackward")  
    tp.IncrementalSearch.SearchBackward()  
    MsgBox("Exit")  
    tp.IncrementalSearch.Exit()  
End Sub  

Remarks

SearchBackward searches backward regardless of the previous direction of the search. It does not modify the pattern.

If a match is found, the editor selection is moved to the new location. The selection is not moved if the search fails.

If the search pattern is empty, SearchBackward simply sets the direction of the search.

Applies to