Visual Basic - An Easy Way to Disable a Multi-line Textbox While Still Allowing Users to Scroll (6)

If you have a scrollable, multi-line textbox that you want to disable for certain users, you might be tempted to just set its Enabled property to False. Unfortunately, if those users still need to see all the data in the field, they won't be able to use the scroll bars, either. Luckily, there's a quick and simple solution to this problem. In the TextBox control's KeyPress() event, place the following line of code:

  • KeyAscii = 0

This line of code prevents the user from entering any additional data in the field, but they will still be able to view the current data.

Go back