user2102327
user2102327

Reputation: 109

Disable the interaction of the mouse with a RichTextBox (all the mouse events to have no influence on the RichTextBox)

What is the equivalent of e.Handled = true in the KeyDown event handler for the MouseDown event handler? I wish none the mouse events to have any effect on the RichTextBox (disable completely the interaction of the mouse with the RichTextBox). More precisely, I wish to prevent the user from marking the text present in the RichTextBox or positioning the cursor anywhere else than the end of the text in the RichTextBox by means of the mouse.

Upvotes: 3

Views: 824

Answers (1)

Alex K.
Alex K.

Reputation: 175766

One way would be to kill off any selection before it begins:

rtb.SelectionChanged += (sender, e) => { rtb.SelectionStart = rtb.TextLength; };

Upvotes: 2

Related Questions