简体   繁体   English

输入更改时可以更改文本框样式吗? (样式表/宏?)

[英]Possible to Change TextBox Style When Input Changes? (Stylesheet/Macro?)

Is it possible to create a macro or stylesheet so that when a TextBox text area is empty, it is yellow per se and when it has data it is white. 是否可以创建宏或样式表,以便当TextBox文本区域为空时,其本身为黄色,而当其具有数据时,则为白色。 I would like to accomplish this without having to explicitly call the TextChanged event. 我想完成此操作而不必显式调用TextChanged事件。

Why not just create a new Custom Control that extends the TextBox and does what you're seeking? 为什么不只创建一个扩展TextBox的新自定义控件,您是否正在寻找所需的内容? That way you can adjust it centrally as well. 这样,您也可以集中调整它。 It would certainly use the TextChanged event however. 当然,它将使用TextChanged事件。 Another way is to put the code in the form, but I think that would be much slower and not reusable. 另一种方法是将代码放入表单中,但是我认为这会慢得多并且不可重用。

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

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