Partager via


TextDocument.MarkText, méthode

Indique si le texte spécifié a été trouvé ou non dans le document texte et crée des signets sans nom lorsqu'une occurrence du texte est trouvée.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
Function MarkText ( _
    Pattern As String, _
    vsFindOptionsValue As Integer _
) As Boolean
bool MarkText(
    string Pattern,
    int vsFindOptionsValue
)
bool MarkText(
    [InAttribute] String^ Pattern, 
    [InAttribute] int vsFindOptionsValue
)
abstract MarkText : 
        Pattern:string * 
        vsFindOptionsValue:int -> bool
function MarkText(
    Pattern : String, 
    vsFindOptionsValue : int
) : boolean

Paramètres

  • Pattern
    Type : String

    Obligatoire. Modèle de texte à rechercher.

  • vsFindOptionsValue
    Type : Int32

    Optionnel. Constante vsFindOptions qui spécifie les options de recherche de texte.

Valeur de retour

Type : Boolean
Valeur booléenne indiquant true si le texte marqué a été trouvé dans le document texte ; retourne false dans le cas contraire.

Notes

MarkText recherche dans l'intégralité du document texte Pattern, en créant automatiquement des signets sans nom à chaque occurrence de Pattern.

Les exemples suivants recherchent le mot "int" dans un document (par exemple, un fichier texte). S'ils le trouvent, un signet est placé sur sa ligne. Les exemples utilisent ensuite la méthode ClearBookmarks pour supprimer les signets.

Pour exécuter l'exemple suivant, commencez par créer ou ouvrir un document contenant le mot "int".

Exemples

Sub MarkTextExample(ByVal dte As EnvDTE.DTE)
    Dim objTD As TextDocument

    objTD = dte.ActiveDocument.Object
    MsgBox("Selection: " & objTD.Selection.Mode.ToString)
    If Not objTD.MarkText("int") Then
        MsgBox("""int"" not found.")
    Else
        MsgBox("Note that unnamed bookmarks have been placed on lines _
        containing ""int"".")
        objTD.ClearBookmarks()
    End If
End Sub
public void MarkTextExample(_DTE dte)
{
    TextDocument td;

    td = (TextDocument)dte.ActiveDocument.Object("");
    MessageBox.Show ("Selection: " + td.Selection.Mode.ToString ());
    if (td.MarkText ("int", (int)vsFindOptions.vsFindOptionsNone) == 
    false)
        MessageBox.Show ("\"int\" not found.");
    else
    {
        MessageBox.Show ("Note that unnamed bookmarks have been placed 
        on lines containing \"int\".");
        td.ClearBookmarks ();
    }
}

Sécurité .NET Framework

Voir aussi

Référence

TextDocument Interface

EnvDTE, espace de noms