简体   繁体   English

TextBox不允许用户键入

[英]TextBox doesnt allow user to type

Hello everyone what I'm trying is in wpf to make that user cant type in textbox. 大家好,我正在尝试在wpf中使该用户无法在文本框中键入内容。 I know there is way just to make it isEnabled = False but if i use it my textbox gets grey color and i cant make it without background! 我知道有一种方法可以使它isEnabled = False,但是如果我使用它,我的文本框将变为灰色,并且如果没有背景,我将使其无法使用! So is there anyway to forbid user entering any char in textbox or any other way? 那么,有没有禁止用户在文本框中或以任何其他方式输入任何字符? Please help 请帮忙

使用TextBox.IsReadOnly属性: http : //msdn.microsoft.com/zh-cn/library/ms753374.aspx

Did you want to dynamically change when the textbox is editable or is it always going to be un-editable? 您是否想在文本框可编辑时动态更改,还是总是无法编辑? You might consider using a label instead if this is the case. 在这种情况下,您可以考虑使用标签代替。 If its dynamic you probably want the backcolor to change to let the user know this is the case. 如果它是动态的,则您可能希望改变背景色,以使用户知道这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM