禁用或使其只读为文本框(.net)中值的一部分 [英] Disabling or making it readonly a part of the values in a Text Box (.net)

查看:79
本文介绍了禁用或使其只读为文本框(.net)中值的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a textbox (multiline) which has initial value, now when user tries to append values to it, he should not be able to modify the initial value. Is it possible in any way?

推荐答案

因此,如果您在框中输入 lorem ipsum,则希望用户能够添加但不删除该文本?如果是这样,则可以使用 RichTextBox 通过选择的 .SelectionProtected 属性,该属性会将区域标记为有效的只读状态。

So if you have "lorem ipsum" in the box you want the user to be able to add to but not remove that text? If so then with a RichTextBox you can do this via a selection's .SelectionProtected property which will mark a region as effectively being read only.

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

这篇关于禁用或使其只读为文本框(.net)中值的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆