JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Making a Text Box Read-only

There are times when you want to make text boxes read-only. For example, you might have written a calculator program in which you let the user enter operands in text boxes and display the result in another text box. The result text box should be read-only, so that the user doesn't enter text there by mistake. You do this with the ReadOnly property.


Main Page

Using the ReadOnly Property

In VB6 and before, you used the Locked property to "lock" a text box so it couldn't be edited, but now the Locked property is used to lock controls in position. Now you use the ReadOnly property to make a text box read-only. Setting this property to True means that the user cannot enter text into the text box (except under your program's control in code).


Main Page

Disabling a Text Box

You also can disable a text box by setting its Enabled property to False. However, although this means the user can't enter text into the text box, it also means the text in the box appears grayed. Disabling is better done to indicate that the control is inaccessible.


Main Page

Using Labels Instead of Text Boxes

Another alternative to using read-only text boxes is to display read-only text in label controls. You can change the text in a label control from code using the label's Text property.

Previous Section Next Section




JavaScript Editor Free JavaScript Editor     JavaScript Editor