My VB.NET programs displays text to the user that is loaded from a text file. I want to highlight specific parts automatically at various intervals depending on what the application is doing.
I can manually set the highlighted text portion using the TextBox control's SelectionStart and SelectionLength members. Unfortunately, this doesn't work if the TextBox control has its ReadOnly member set to True. What is strange is that my program allows the user to manually click-drag selected text, but text does not get highlighted if the selection is performed programmatically.
The text must be read-only since I do not want the user to modify it. Is there a solution to this?
You can use the TextBox SelectionStart and SelectionLength properties, but I'm guessing since the TextBox is ReadOnly, it probably doesn't have the focus.
Try setting this property:
TextBox1.HideSelection = False
It should work as you expect to now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With