0

I'm trying to create a search text box that will allow the user to enter text, and then when the button is pressed it will searching the richtextbox to search for a match and highlight the matching text. However when reading examples of how to do this people use:

RichTextBox.Text 

but I don't have a text property, so I can't type that and can't see another way around. Why doesn't the .Text appear?

karel
  • 5,489
  • 46
  • 45
  • 50
Rubik
  • 49
  • 5

1 Answers1

0

You have to use the ".Document.ContentStart" to ".Document.ContentEnd" getter since its in rich text format, with add'l formatting. There is ideally formatted text indicators and artifacts inside of your text box such as bold, paragraph properties and font types. You're going to have to set the predefined ranges using the '.Document.' property, that denotes you want just the text:

var txtReturn = TextRange(RichTextBox.Document.ContentStart,
        RichTextBox.Document.ContentEnd).Text;
Console.WriteLine(txtReturn);
apollosoftware.org
  • 12,161
  • 4
  • 48
  • 69