Documentation
-
How to: Create a Read-Only Text Box - Windows Forms
Learn about transforming an editable Windows Forms text box into a read-only Windows Forms text box.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
By default, the Windows Forms RichTextBox control displays horizontal and vertical scroll bars as necessary. There are seven possible values for the ScrollBars property of the RichTextBox control, which are described in the table below.
Set the Multiline property to true
. No type of scroll bar, including horizontal, will display if the Multiline property is set to false
.
Set the ScrollBars property to an appropriate value of the RichTextBoxScrollBars enumeration.
Value | Description |
---|---|
Both (default) | Displays horizontal or vertical scroll bars, or both, only when text exceeds the width or length of the control. |
None | Never displays any type of scroll bar. |
Horizontal | Displays a horizontal scroll bar only when the text exceeds the width of the control. (For this to occur, the WordWrap property must be set to false .) |
Vertical | Displays a vertical scroll bar only when the text exceeds the height of the control. |
ForcedHorizontal | Displays a horizontal scroll bar when the WordWrap property is set to false . The scroll bar appears dimmed when text does not exceed the width of the control. |
ForcedVertical | Always displays a vertical scroll bar. The scroll bar appears dimmed when text does not exceed the length of the control. |
ForcedBoth | Always displays a vertical scrollbar. Displays a horizontal scroll bar when the WordWrap property is set to false . The scroll bars appear grayed when text does not exceed the width or length of the control. |
Set the WordWrap property to an appropriate value.
Value | Description |
---|---|
false |
Text in the control is not automatically adjusted to fit the width of the control, so it will scroll to the right until a line break is reached. Use this value if you chose horizontal scroll bars or both, above. |
true (default) |
Text in the control is automatically adjusted to fit the width of the control. The horizontal scrollbar will not appear. Use this value if you chose vertical scroll bars or none, above, to display one or more paragraphs. |
.NET Desktop feedback feedback
.NET Desktop feedback is an open source project. Select a link to provide feedback:
Documentation
How to: Create a Read-Only Text Box - Windows Forms
Learn about transforming an editable Windows Forms text box into a read-only Windows Forms text box.
Training
Module
Format alphanumeric data for presentation in C# - Training
Explore basic methods in C# to format alphanumeric data.