How to disable textbox from editing?

C#WinformsTextbox

C# Problem Overview


I want to use a text box to display some text. I can not disable it, because then the scroll bar will not work.

How can I prevent editing within the multi-line textbox, yet make it appear as if it is enabled, so that the scroll bar works correctly?

C# Solutions


Solution 1 - C#

You can set the ReadOnly property to true.

Quoth the link:

> When this property is set to true, the contents of the control cannot > be changed by the user at runtime. With this property set to true, you > can still set the value of the Text property in code. You can use this > feature instead of disabling the control with the Enabled property to > allow the contents to be copied and ToolTips to be shown.

Solution 2 - C#

The TextBox has a property called ReadOnly. If you set that property to true then the TextBox will still be able to scroll but the user wont be able to change the value.

Solution 3 - C#

As mentioned above, you can change the property of the textbox "Read Only" to "True" from the properties window.

enter image description here

Solution 4 - C#

        textBox1.ReadOnly = true;

"true" property will make the text box readonly activate. and "false" will make it in regular form. Thanks.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHelpNeederView Question on Stackoverflow
Solution 1 - C#Austin SalonenView Answer on Stackoverflow
Solution 2 - C#norlandoView Answer on Stackoverflow
Solution 3 - C#FUSION CHA0SView Answer on Stackoverflow
Solution 4 - C#AmmarView Answer on Stackoverflow