473,385 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1847
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: techfuzz | last post by:
I scoured this group and others looking for the best way to disable a button after the first click to prevent multiple submissions, but never did find anything that worked like they said it would. ...
9
by: Daniel Walzenbach | last post by:
Hi I am faced with the following problem: I have a page (let’s call this page page1.aspx) containing some TextBoxes and a hyperlink which opens another page (let’s call this page page2.aspx)...
24
by: Charles Law | last post by:
When I click a button I don't want the click event to fire. Is this possible? In fact, what I would really like is to be able to intercept the click event, perform some action, and then prevent...
14
by: Ed Jay | last post by:
On a multi-textbox form, linked to an external js, I use onBlur to call: function chkNum(cellname) { var str = document.getElementById(cellname).value.toString(10); if (str < 28 || str > 36)...
0
by: josephkorn | last post by:
Hi all. I have a problem in my website in trying to prevent a user from double submitting the form. I am calling a subroutine from my page_load event that passes in the commandbutton that I want...
5
by: Vincent | last post by:
I have a bound listbox control on one of my forms that has an associated afterupdate event. When this event is invoked, I lock the control to prevent the user from clicking on it more than once....
2
by: AjitGoel | last post by:
Hi; I need to create a custom textbox control which will not allow a user to paste text from the clipboard. The user has to always type the text into the textbox. I tried searching on the...
4
by: PJ6 | last post by:
Is there a way to prevent the double-click event on an element from causing IE6 to select everything? Cancelling the event doesn't work. Paul
3
by: WISEMANOFNARNIA | last post by:
I would like to prevent a user from exiting a page by clicking on links. the only way he should be able to exit is clicking on a 'save' button or a 'cancel' button. I can see that javascript is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.