如何实现显示&QUOT一个文本框,在此键入"? [英] How do I implement a TextBox that displays "Type here"?

查看:165
本文介绍了如何实现显示&QUOT一个文本框,在此键入"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显示的键入这里... 的,直到用户输入文本成文本框是时下一个众所周知的可用性功能。如何将一个C#实现这个功能吗?

Displaying "Type here to ..." until the user enters text into a TextBox is a well-known usability feature nowadays. How would one implement this feature in C#?

我的想法是覆盖 OnTextChanged ,而是从和处理文本的变化逻辑的在此键入是一个有点棘手...

My idea is to override OnTextChanged, but the logic to handle the changes of text from and to "Type here" is a bit tricky...

显示的在此输入的关于初始化和第一次输入删除它很容易,但我希望每一个输入的文本为空时要显示的消息。

Displaying "Type here" on initialization and removing it on first input is easy, but I want to display the message every time the entered text becomes empty.

推荐答案

什么你要找的是一个texbox水印

What you're looking for is a texbox with "watermark"

有对C#一个样本实现这里

希望它能帮助

这篇关于如何实现显示&QUOT一个文本框,在此键入"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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