Is there a way to prevent a user being able to click on the text a

G

Guest

Hi, I'm using vs2005, .net 2 for a windows application. I have a
richtextbox control on my form that I make it readonly.
1. Do I need to make readonly to be false to append text to it?
2. Even though I chose the Cursor property of the richtextbox to be "No"
but when I run the application I can still click on the RTB and got a Ibeam
cursor among my text. Is there a way to prevent a user being able to click
on the text and get the ibeam cursor? Even though I can't type in it but
it's just doesn't look right.

Thanks.
 
P

Peter Duniho

Hi, I'm using vs2005, .net 2 for a windows application. I have a
richtextbox control on my form that I make it readonly.
1. Do I need to make readonly to be false to append text to it?

No. ReadOnly pertains to user interactions. You can still set the Text
property yourself.
2. Even though I chose the Cursor property of the richtextbox to be "No"
but when I run the application I can still click on the RTB and got a
Ibeam
cursor among my text. Is there a way to prevent a user being able to
click
on the text and get the ibeam cursor? Even though I can't type in it but
it's just doesn't look right.

Depends on how you want the text to look. You can disable the control,
but then the text will be greyed out.

To me, the ability to click and select text in a read-only textbox is a
feature. It allows me to present text to the user, which they can copy
and paste elsewhere, but which they cannot themselves change.

Are you actually taking advantage of the rich-text formatting in the
RichTextBox? If not, it sounds like you might prefer using the Label
control, which will show text similarly to the ReadOnly textbox, but
without allowing the user to select it.

If you want rich-text formatting, don't want the user to select the text,
and don't want the text displayed greyed out from disabling, then maybe
you can lobby Microsoft to include a RichLabel class in the next version
of .NET. :)

In the meantime, you might have some success intercepting mouse events in
a subclassed version of RichTextBox in which you've overridden the WndProc
method. Just intercept and don't pass along any mouse events, and that
may get you the behavior you want.

Pete
 
G

Guest

Thank you Peter for such detail answer to my question. It makes a lot of
sense now. I think I will leave the Ibeam cursor since it is a feature and
allows select and copy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top