How can I make a read-only TextBox or RichTextBox?
Posted on 1998-08-30
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.