Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CueProvider

0.00/5 (No votes)
24 Jul 2008 1  
A lightweight class that lets you add cues to a TextBox.

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.

CueProvider demo

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.

  // Set cue text
  CueProvider.SetCue (theTextBox, theCueText);

  // Clear cue text
  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

  • 24 Jul 2008
  • Updated the "How to use" section.

  • 17 Jul 2008
  • Initial version.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here