c# - 如何禁止编辑文本框?

标签 c# winforms textbox

我想用一个文本框来显示一些文本。我无法禁用它,因为那样滚动条将不起作用。

如何防止在多行文本框内进行编辑,同时使其看起来好像已启用,以便滚动条正常工作?

最佳答案

您可以设置 ReadOnly property为真。

引用链接:

When this property is set to true, the contents of the control cannot be changed by the user at runtime. With this property set to true, you can still set the value of the Text property in code. 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.

关于c# - 如何禁止编辑文本框?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8330430/

相关文章:

c# - 如何使用 xpath 从 xml 中检索元素值?

c# - 迁移到 .NET Core 6 后 Blazor PageTitle 标签不起作用

c# - 将对象序列化为已包含一个 JSON 属性的 JSON

c# - Winforms:从不同的类调用输入表单函数

c# - 在标签中获取 http 文件大小、下载位置和 URL

c# - 使用来自另一个项目的用户控件

wpf - 更改托管到 Winform 的依赖项属性(在 ViewModel 中)

C# - 从 RichTextBox 和 TextBox 添加两个数字

vb.net - 将字符串拆分为 2 个变量

wpf - 当 WPF TextBox 获得焦点时,如何轻松更改它的样式?