Introduction
CueProvider
is a tiny class that lets you set a cue banner (the grey prompt text that automatically disappears when you begin to type) in a TextBox
control.
How to use CueProvider
CueProvider
is easy to use, and has just two methods - one to set a TextBox
's cue text, the other to clear it. To set the cue text, call SetCue()
; to clear it, call ClearCue()
. These calls are best placed in your form's OnLoad
handler.
CueProvider.SetCue (theTextBox, theCueText);
CueProvider.ClearCue (theTextBox);
How it works
CueProvider
works by sending the TextBox
the EM_SETCUEBANNER
message. The message is sent using the SendMessage()
Win32 API. More information on the EM_SETCUEBANNER
message can be found on this MSDN page.
Conclusion
As you can see, there's nothing overly complicated in this class. I put CueBanner
together in a few minutes, and wanted to share it with the CodeProject community in the hope it could help give our desktop apps a bit of UI "polish".
Revision history