473,675 Members | 4,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1859
On Fri, 06 Jul 2007 21:38:02 -0700, Pucca
<Pu***@discussi ons.microsoft.c omwrote:
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***@discussi ons.microsoft.c omwrote:
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
13266
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. I went ahead and wrote my own bit of code so I'm sharing it here for everyone. Even though it doesn't really disable the button by greying it out, it prevents the multiple submissions which it what I was attempting to prevent all along. ...
9
2277
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) as a popup using either window.open or window.showModalDialog. Since I want to warn the users of my application when they try to close page1.aspx and have changed the values in the meantime I thought about using the “onbeforeunload” event of the...
24
7671
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 the click from passing through to the button. Any help or suggestions much appreciated. Charles
14
2337
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) {alert("Temperature entered is out of range."); return;} } I enter data into the first textbox and move the cursor to the second textbox. The function is properly called. Since textbox2 is empty, when I
0
6178
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 to prevent users from being able to click twice. Everything is working great, except for one small detail. When my client-side validation fires, and is invalid, I see the red text that displays the error message, but the problem is that something is...
5
9997
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. However, it appears that Access is queuing the mouse clicks and calling the afterupdate event regardless of whether the control is locked or not. If I click the mouse quickly, Access generates the following error message: "The macro or function...
2
2275
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 internet since I guessed someone would have faced this problem before but of no avail. Do we have pointers on how I should go about doing this??
4
2147
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
4718
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 the only way to prevent him from closing his browser completely before doing a 'save', but I was wondering if asp.net had a way of preventing him from leaving the page by clicking on links. The following code does not work - in fact it gives an...
0
8440
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8964
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8667
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6274
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
5744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4259
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
1859
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.