I have a WPF .NET 4 C# RichTextBox and I’m wanting to replace certain characters within that text box with other characters, this is to happen on the KeyUp event.
What I’m trying to achieve is replace acronyms with full words, e.g.:
pc = personal computer
sc = starcraft
etc…
I’ve looked a few similar threads, but anything I’ve found hasn’t been successful in my scenario.
Ultimately, I’d like to be able to do this with a list of acronyms. However, I’m having issues with even replacing a single acronym, can anyone help?
Because
System.Windows.Controls.RichTextBoxdoes not have a property forTextto detect its value, you may detect its value using the followingThen, you may change
_Textand post the new string using the followingSo, it’d look like this
Remark: Instead of using
Text.Replace("pc", "Personal Computer");you may declare aList<String>in which you save the characters and its replacementsExample:
Thanks,
I hope you find this helpful 🙂