Solved

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

Posted on 1998-08-30
4
574 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

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

Accepted Solution

by:
Dalin earned 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
passing parameter in sql procedure 9 70
VBA Shell can't Find Word document 11 155
Problem to line 23 81
Visual Basic 6: Code needed for TripleDES Encryption/Decryption 14 95
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

710 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