TextBoxBase.ReadOnly 属性


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

 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.