Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在文本框中显示占位符值。当用户尝试在文本框中输入时,它将自动从文本框中删除。任何人都可以解决它吗?
当文本框获得焦点和失去焦点时使用事件。当文本框获得焦点时,您会执行类似MytextBox.Text = string.Emtpy失去焦点时的操作,您检查它是否有内容,如果没有,则将其设置为默认值,例如: string.IsNullOrWhiteSpace(MytextBox.Text) ? "Default" : MytextBox.Text
MytextBox.Text = string.Emtpy
string.IsNullOrWhiteSpace(MytextBox.Text) ? "Default" : MytextBox.Text