Udostępnij za pośrednictwem


RichTextBox.AcceptsReturn Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets a value that determines whether the RichTextBox allows and displays the newline or return characters when the ENTER or RETURN keys are pressed.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property AcceptsReturn As Boolean
public bool AcceptsReturn { get; set; }
<RichTextBox AcceptsReturn="bool"/>

Property Value

Type: System.Boolean
true if the RichTextBox allows newline characters; otherwise, false. The default is true.

Remarks

You can disable multi-line content in a RichTextBox control by using the AcceptsReturn property. Use the HorizontalScrollBarVisibility or VerticalScrollBarVisibility to enable the horizontal scrollbars or the vertical scrollbars.

Examples

The following XAML shows how to use the AcceptsReturn property.

<RichTextBox Margin="20,20,0,0" Width="300" Height="50" TextWrapping="Wrap" AcceptsReturn="True">
    <Paragraph>
        A RichTextBox that demonstrates TextWrapping and AcceptsReturn properties
    </Paragraph>
</RichTextBox>

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.