SelectedText dans un richtextbox

Résolu
kiboumz Messages postés 120 Date d'inscription mercredi 17 septembre 2003 Statut Membre Dernière intervention 18 mai 2007 - 26 mai 2006 à 20:54
kiboumz Messages postés 120 Date d'inscription mercredi 17 septembre 2003 Statut Membre Dernière intervention 18 mai 2007 - 29 mai 2006 à 19:25
Bonjour,

j'essaie de faire dans mon programme une fonction de recherche qui sélectionne (highlight), dans le richtextbox, le texte recherché, mais je n'y arrive pas.

J'ai ceci :

int Position = richtxtboxDocument.Text.IndexOf(txtboxRechercher.Text);
if (Position != -1)
{
     richtxtboxDocument.SelectionStart = Position;
     richtxtboxDocument.SelectionLength = txtboxRechercher.Text.Length;
}

Cependant, il ne sélectionne rien ... jamais ...

Merci
a+

2 réponses

cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
26 mai 2006 à 21:27
Salut,

Met la propriété HideSelection à false pour pouvoir voir la sélection quand le contrôle n'a pas le focus.

/*
coq
MVP Visual C#
*/
3
kiboumz Messages postés 120 Date d'inscription mercredi 17 septembre 2003 Statut Membre Dernière intervention 18 mai 2007
29 mai 2006 à 19:25
Salut,

C'était effectivement la propriété HideSelection qui était à true ...

Merci!
a+
0
Rejoignez-nous