[英]Disable first line of textbox
I made a program like notepad. 我做了一个记事本之类的程序。 I want the first line to be the date and time when the note was made.
我希望第一行是做笔记的日期和时间。 I get this with:
我得到这个:
tbEditor.Text = Convert.ToString(DateTime.Now);
But is it possible to disable this first line so the user can't delete it afterwords? 但是是否可以禁用第一行,以便用户无法删除后记?
Use a or to display data that doesn't require user intervention. 使用或来显示不需要用户干预的数据。 You can use a stack with textblock and then a text box in it to store date and user note respectively.
您可以使用带有文本块的堆栈,然后在其中使用文本框来分别存储日期和用户注释。 Alternatively, if you want to use a textbox, you can set IsReadOnly property to true OR IsEnabled property to false.
或者,如果要使用文本框,可以将IsReadOnly属性设置为true或将IsEnabled属性设置为false。 But this is not just for the first line, but for the whole textbox.
但这不仅用于第一行,而且适用于整个文本框。 So you would need a separate control to store the Date and Time
因此,您需要一个单独的控件来存储日期和时间
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.