显示一个提示一个C#的WinForms编辑控件 [英] Showing a hint for a C# winforms edit control
问题描述
我工作的一个C#WinForms应用程序(VS.NET 2008,.NET 3.5 SP 1)。我有一个窗体上的搜索栏,而非有旁边的搜索字段标签,我想展示在搜索领域本身的一些背景灰色文本(搜索字词,例如)。当用户开始在搜索栏中输入文本的文本应消失。我怎样才能做到这一点?
I'm working on a C# winforms application (VS.NET 2008, .NET 3.5 sp 1). I have a search field on a form, and rather than have a label next to the search field I'd like to show some grey text in the background of the search field itself ('Search terms', for example). When the user starts entering text in the search field the text should disappear. How can I achieve this?
推荐答案
您将需要使用一些P / Inovke互操作的代码来做到这一点。寻找在Win32 API SendMessage函数
函数和 EM_SETCUEBANNER
消息。
You will need to use some P/Inovke interop code to do this. Look for the Win32 API SendMessage
function and the EM_SETCUEBANNER
message.
这篇关于显示一个提示一个C#的WinForms编辑控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!