Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How can I make a read-only TextBox or RichTextBox?

Posted on 1998-08-30
4
Medium Priority
?
593 Views
Last Modified: 2012-06-21
I am using TextBoxes and RichTextBoxes for display only purposes and want to be able to make them read-only.  The user must not be able to interact with the control in any way (not even be able to select text or move the cursor inside), EXCEPT, if the box is too small to display all of the information, the user must still be able to use the scroll bars.

There are two simple ways in VB to do something similar, but both are unsatisfactory...

1) Set Locked property to true - This makes the control read-only, however the user can still select text, move the cursor within the control etc.  I don't want this functionality.

2) Set Enabled property to false - This make the control "read-only" too, but the control becomes grayed out making it more difficult to see.  Also, the user can't access the scoll bars.

I'm using VB 4 Enterprise Edition.  Maybe this behaviour could be achieved by issuing 1 or more Windows messages to the control using SendMessage()?  Thanks for your help.
0
Comment
Question by:Richard2000
  • 2
4 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1431970
What is the Question?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 200 total points
ID: 1431971
Richard2000,


Set the locked property to true, and in the textbox's gotfocus event add:
command1.setfocus

You can replace command1 with the name of the control that you like it to receive focus.

0
 

Expert Comment

by:mskannan
ID: 1431972
Hi Richard,
In the keypress event of the testbox, just type
keyascii = 0
This will  give you the solution for your problem
Regards,
mskannan
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1431973
mskanan,
Not realy. The user can highlight part or all the test with the mouse, and cut/copy/paste from the menu if there is one.
Regards
Dalin
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question