Click here to Skip to main content
5,787,682 members and growing! (21,802 online)
Email Password   helpLost your password?
Desktop Development » Edit Controls » General     Intermediate License: The Code Project Open License (CPOL)

CueProvider

By Ravi Bhavnani

A lightweight class that lets you add cues to a TextBox.
C#, Windows, .NET, Dev

Posted: 16 Jul 2008
Updated: 24 Jul 2008
Views: 12,488
Bookmarked: 39 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
16 votes for this Article.
Popularity: 5.50 Rating: 4.57 out of 5
0 votes, 0.0%
1
1 vote, 6.3%
2
1 vote, 6.3%
3
3 votes, 18.8%
4
11 votes, 68.8%
5

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ravi Bhavnani


Ravi Bhavnani is an ardent fan of Microsoft technologies who loves building Windows apps, especially PIMs, system utilities, and things that go bump on the Internet. During his career, Ravi has developed expert systems, desktop imaging apps, enterprise marketing automation software, EDA tools, a platform to help people find, analyze and understand information, and trading software for institutional investors. He currently works for a company that provides advanced data visualization solutions for Microsoft technologies.

His interests include the .NET framework, reasoning systems, financial analysis and algorithmic trading, intelligent agents, NLP, CHI and UI design. Ravi holds a BS in Physics and Math and an MS in Computer Science and is a Microsoft C# MVP. His claim to fame is that he crafted CodeProject's "joke" forum post icon.

Ravi's biggest fear is that one day he might actually get a life, although the chances of that happening seem extremely remote.

Occupation: Software Developer (Senior)
Company: Dundas Software
Location: Canada Canada

Other popular Edit Controls articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 40 (Total in Forum: 40) (Refresh)FirstPrevNext
GeneralCueProvider and MaskedTextBoxmemberzonextrem4:47 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBoxmemberRavi Bhavnani9:16 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBoxmemberzonextrem9:19 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBoxmemberRavi Bhavnani9:22 12 Aug '08  
GeneralDemo not working :(memberbaruchl23:22 28 Jul '08  
AnswerRe: Demo not working :(memberRavi Bhavnani2:46 29 Jul '08  
GeneralRe: Demo not working :(memberTobiasP4:41 30 Jul '08  
GeneralRe: Demo not working :(memberRavi Bhavnani4:48 30 Jul '08  
GeneralNot working!!!memberQing Jiang5:52 25 Jul '08  
GeneralRe: Not working!!!memberRavi Bhavnani7:39 25 Jul '08  
Generalnot workinmemberpro.rakesh0:58 25 Jul '08  
GeneralRe: not workinmemberRavi Bhavnani7:40 25 Jul '08  
GeneralI modified it to do an IExtenderProvider component [modified]memberFabrice CARUSO21:11 24 Jul '08  
GeneralRe: I modified it to do an IExtenderProvider componentmemberRavi Bhavnani7:39 25 Jul '08  
GeneralA few suggestions...mvpScott Dorman18:11 24 Jul '08  
GeneralRe: A few suggestions...memberRavi Bhavnani7:38 25 Jul '08  
GeneralRe: A few suggestions...mvpScott Dorman15:19 25 Jul '08  
GeneralRe: A few suggestions...memberRavi Bhavnani20:21 25 Jul '08  
GeneralNot working...memberhenur7:59 22 Jul '08  
GeneralRe: Not working...memberRavi Bhavnani8:51 22 Jul '08  
GeneralRe: Not working...memberhenur22:48 22 Jul '08  
GeneralRe: Not working...memberRavi Bhavnani7:55 23 Jul '08  
AnswerRe: Not working...memberRavi Bhavnani12:52 24 Jul '08  
GeneralRe: Not working...memberhenur22:12 26 Jul '08  
GeneralRe: Not working...memberRavi Bhavnani8:26 27 Jul '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Jul 2008
Editor: Smitha Vijayan
Copyright 2008 by Ravi Bhavnani
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project