TextBoxBase.ReadOnly 属性

定义

获取或设置一个值,该值指示文本框中的文本是否为只读。Gets or sets a value indicating whether text in the text box is read-only.

public:
 property bool ReadOnly { bool get(); void set(bool value); };
public bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
Public Property ReadOnly As Boolean

属性值

如果文本框是只读的,则为 true,否则为 falsetrue if the text box is read-only; otherwise, false. 默认值为 falseThe default is false.

注解

当此属性设置为 true时,用户不能在运行时更改控件的内容。When this property is set to true, the contents of the control cannot be changed by the user at runtime. 如果将此属性设置为 true,你仍可以在代码中设置 Text 属性的值。With this property set to true, you can still set the value of the Text property in code. 您可以使用此功能,而不是使用 Enabled 属性禁用控件,以允许复制内容和显示工具提示。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.

适用于