禁用或使其只读成为文本框 (.net) 中值的一部分

Ani*_*nil 5 .net c# winforms

我有一个具有初始值的文本框(多行),现在当用户尝试向其附加值时,他应该无法修改初始值。有可能吗?

Ale*_* K. 5

因此,如果您希望用户能够添加但不删除该文本的框中有“lorem ipsum”?如果是这样,那么使用RichTextBox,您可以通过选择的.SelectionProtected属性来完成此操作,该属性会将区域标记为有效只读。

rtBox.Select(0, (rtBox.Text = "I am fixed content").Length);
rtBox.SelectionProtected = true;
rtBox.AppendText(Environment.NewLine);
Run Code Online (Sandbox Code Playgroud)


FIr*_*nda 1

您可以使用 RichTextBoxSelectionProtected属性。