Click here to Skip to main content
6,595,444 members and growing! (19,880 online)
Email Password   helpLost your password?
Desktop Development » Edit Controls » General License: The Code Project Open License (CPOL)

CueProvider

By Ravi Bhavnani

A lightweight class that lets you add cues to a TextBox.
C#
Posted:16 Jul 2008
Updated:24 Jul 2008
Views:22,675
Bookmarked:48 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
17 votes for this article.
Popularity: 5.59 Rating: 4.54 out of 5

1
1 vote, 5.9%
2
1 vote, 5.9%
3
4 votes, 23.5%
4
11 votes, 64.7%
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


Member
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, 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
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 40 (Total in Forum: 40) (Refresh)FirstPrevNext
GeneralCueProvider and MaskedTextBox Pinmemberzonextrem4:47 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBox PinmemberRavi Bhavnani9:16 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBox Pinmemberzonextrem9:19 12 Aug '08  
GeneralRe: CueProvider and MaskedTextBox PinmemberRavi Bhavnani9:22 12 Aug '08  
GeneralDemo not working :( Pinmemberbaruchl23:22 28 Jul '08  
AnswerRe: Demo not working :( PinmemberRavi Bhavnani2:46 29 Jul '08  
GeneralRe: Demo not working :( PinmemberTobiasP4:41 30 Jul '08  
GeneralRe: Demo not working :( PinmemberRavi Bhavnani4:48 30 Jul '08  
GeneralNot working!!! PinmemberQing Jiang5:52 25 Jul '08  
GeneralRe: Not working!!! PinmemberRavi Bhavnani7:39 25 Jul '08  
Generalnot workin Pinmemberpro.rakesh0:58 25 Jul '08  
GeneralRe: not workin PinmemberRavi Bhavnani7:40 25 Jul '08  
GeneralI modified it to do an IExtenderProvider component [modified] PinmemberFabrice CARUSO21:11 24 Jul '08  
GeneralRe: I modified it to do an IExtenderProvider component PinmemberRavi Bhavnani7:39 25 Jul '08  
GeneralA few suggestions... PinmvpScott Dorman18:11 24 Jul '08  
GeneralRe: A few suggestions... PinmemberRavi Bhavnani7:38 25 Jul '08  
GeneralRe: A few suggestions... PinmvpScott Dorman15:19 25 Jul '08  
GeneralRe: A few suggestions... PinmemberRavi Bhavnani20:21 25 Jul '08  
GeneralNot working... Pinmemberhenur7:59 22 Jul '08  
GeneralRe: Not working... PinmemberRavi Bhavnani8:51 22 Jul '08  
GeneralRe: Not working... Pinmemberhenur22:48 22 Jul '08  
GeneralRe: Not working... PinmemberRavi Bhavnani7:55 23 Jul '08  
AnswerRe: Not working... PinmemberRavi Bhavnani12:52 24 Jul '08  
GeneralRe: Not working... Pinmemberhenur22:12 26 Jul '08  
GeneralRe: Not working... PinmemberRavi 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
Web21 | Advertise on the Code Project