[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

How to prevent selection of text in a text control (e.g. textbox or richtextbox

Hi all!
I have a richtextbox control which I want to make available to users.
They can read its contents but I don't want them to be able to select any text or copy them

What I have done
1. I set the property of the control to read only
2. I wrote this

 if(rtfCase.SelectedText.Length > 0)rtfCase.SelectedText = "";

in the MouseUp, KeyUp and SelectionChanged events of the RTF control, but no luck.
Can someone please help me out.

Thank you
1 Solution
I would simply set the Enabled property of the control to false.
If you don't want to do that then you could use the selectionChanged event as follows:
private void rtf_SelectionChanged(object sender, System.EventArgs e)
innovator2Author Commented:
Thanks. It works fine.

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now