Tag Archives: textbox cue text

Set placeholder text for textbox (cue text)

Setting placeholder text for your textboxes helps the users to identify better what kind of information it’s needed from them.

Instead of handling the focus enter and focus leave events in order to set and remove the placeholder text it is possible to use the Windows SendMessage function to send a EM_SETCUEBANNER message to our textbox to do the work for us.

This can be done with two easy steps. First we need to expose the Windows SendMessage function.

Then simply call the method with the handle of our textbox, EM_SETCUEBANNER’s value and the text we want to set.

The result will be a textbox with a placeholder text of our choice. The placeholder text will be automatically be removed when the textbox gains focus and will only reappear if the textbox loses focus and has no characters typed in it.

Cue text example