Click here to Skip to main content
12,824,787 members (41,362 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 7 May 2013

TextBox with Placeholder

, 2 Sep 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Extended TextBox with placeholder


In many cases, a TextBox with an easy Placeholder property would be very helpful especially when you want the user to filter a ListView or ListBox by search terms.

So, I never found a really good one. I know there exists a very easy method with only one SendMessage method, but I don't like it because the placeholder is hard to differentiate with the actually typed text and I don't like these message things very much, too many things can go wrong.

Now I created my own control and my destination is that it is very easy to use.

Using the Code

Add the PlaceholderTextBox.cs to your project and build it. You can add it with the designer now.

The difference to the usual TextBox is it that there are three new properties:

  • PlaceholderText: It's not hard to guess what this property does. It defines the Placeholder text which will get displayed if the TextBox is empty.
  • IsPlaceholderActive: Through this property, you can always check if the textbox shows the placeholder or real text at the moment.

PlaceholderText is accessible with the designer, IsPlaceholderActive is not!

Besides, there is the new method Reset(). This will return the TextBox to the start state.

The Text property is not accessible with the designer. That's to keep the standard. The placeholder should always be seen before you type any text in the TextBox.

Points of Interest

It's a very well written code. I recommend you read it, there are many comments and maybe you have a suggestion.

I hope you like my control and when you have any suggestions or have found a bug, please let me know!



  • Fixed bug: Font can be changed now - Thanks to Member 11133660
  • Improved internal logic
  • Removed IsItalics
  • Renamed PlaceholderInsideChanged to PlaceholderActiveChanged


  • Improved internal logic
  • Removed sealed
  • Added Placeholder category to designer for better overview
  • Fixed some comments


  • Added PlaceholderInsideChanged event
  • Fixed bug that new MouseDownEvents never occur
  • Prevents user to go through placeholder with arrow keys


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionOther Objects... like MaskedEditBox and Combobox. Pin
Eagles_Power24-Jan-17 3:45
memberEagles_Power24-Jan-17 3:45 
GeneralMy vote of 5 Pin
Maxwolf Goodliffe12-Dec-14 8:08
memberMaxwolf Goodliffe12-Dec-14 8:08 
QuestionDownload demo project link is broken Pin
Member 1125706523-Nov-14 4:26
memberMember 1125706523-Nov-14 4:26 
BugCustom Font is not applied Pin
Member 111336606-Oct-14 13:55
memberMember 111336606-Oct-14 13:55 
GeneralRe: Custom Font is not applied Pin
AndyFTW7-Oct-14 4:25
memberAndyFTW7-Oct-14 4:25 
GeneralPlease show and explain the code Pin
PIEBALDconsult4-Sep-13 19:38
professionalPIEBALDconsult4-Sep-13 19:38 
Question[My vote of 1] Win Form now? Pin
David Furshpan4-Sep-13 14:30
memberDavid Furshpan4-Sep-13 14:30 
AnswerRe: [My vote of 1] Win Form now? Pin
AndyFTW6-Sep-13 3:23
memberAndyFTW6-Sep-13 3:23 
AnswerRe: [My vote of 1] Win Form now? Pin
FernandoUY6-Sep-13 9:08
memberFernandoUY6-Sep-13 9:08 
GeneralMy vote of 5 Pin
Meng FanRui4-Sep-13 0:51
memberMeng FanRui4-Sep-13 0:51 
GeneralMy vote of 2 Pin
FernandoUY2-Sep-13 15:09
memberFernandoUY2-Sep-13 15:09 
GeneralRe: My vote of 2 Pin
AndyFTW6-Sep-13 3:22
memberAndyFTW6-Sep-13 3:22 
GeneralRe: My vote of 2 Pin
FernandoUY6-Sep-13 9:05
memberFernandoUY6-Sep-13 9:05 
QuestionNot an article Pin
OriginalGriff16-May-13 3:29
protectorOriginalGriff16-May-13 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170308.1 | Last Updated 2 Sep 2013
Article Copyright 2013 by AndyFTW
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid