Поделиться через


TextBox.IsReadOnly Property

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

Gets or sets the value that determines if the user can change the text in the text box.

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

Syntax

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

Property Value

Type: System.Boolean
true if the text box is read-only; otherwise, false. The default is false.

Remarks

Dependency property identifier field: IsReadOnlyProperty.

If the text box is read-only, no user input or edits are allowed, but programmatic changes can be made. The user can still select text, and the cursor still appears. The KeyUp and KeyDown events are marked as handled.

Examples

The following code snippet displays a read-only text box.

<TextBlock Margin="20,20,0,0" Text="Read Only TextBox"/>

<TextBox x:Name="ReadOnlyTB"  IsReadOnly="True" HorizontalAlignment="Left" Margin="20,5,0,0" Height="35" Width="200" />

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

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