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?
Set the TextBox control's ReadOnly property to true . With the property set to true , users can still scroll and highlight text in a text box without allowing changes.
The IsReadOnly property of the TextBox sets the text box read only. By default, it is false. The MaxLength property of the TextBox sets the number of characters allowed to input in a text box.
You can make the TextBox as read-only by setting the readonly attribute to the input element.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With