How to change the Devexpress TextEdit current text on focus

aby picture aby · Apr 10, 2012 · Viewed 8.8k times · Source

I've a Devexpress TextEdit control that displays a string something like "24 year." I want the text "years" to disappear every time the user clicks inside the text box (for editing purpose). And, I want the text to reappear when the focus is lost. How can i do this?

Thanks in advance

Answer

DmitryG picture DmitryG · Apr 10, 2012

I believe you're working with the TextEdit. Thus you can use the following code snippet:

textEdit.Properties.DisplayFormat.FormatString = "{0:d2} Year";
textEdit.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
textEdit.Properties.Mask.EditMask = "\\d{1,2}";
textEdit.Properties.Mask.IgnoreMaskBlank = false;
textEdit.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Regular;
textEdit.Properties.NullText = "Type your age here";

Here are related help topics: