468,785 Members | 1,469 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

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

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.
--
Thanks.
Jul 7 '07 #1
2 1699
On Fri, 06 Jul 2007 21:38:02 -0700, Pucca
<Pu***@discussions.microsoft.comwrote:
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
Jul 7 '07 #2
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.
--
Thanks.
"Peter Duniho" wrote:
On Fri, 06 Jul 2007 21:38:02 -0700, Pucca
<Pu***@discussions.microsoft.comwrote:
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
Jul 8 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Daniel Walzenbach | last post: by
14 posts views Thread by Ed Jay | last post: by
5 posts views Thread by Vincent | last post: by
2 posts views Thread by AjitGoel | last post: by
3 posts views Thread by WISEMANOFNARNIA | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.