Basic Library for WPF and Silverlight | ComponentOne
WPF and Silverlight Edition Basic Library / Masked Text Box / MaskedTextBox Features / Prompts
In This Topic
    Prompts
    In This Topic

    You can choose to include prompt characters in the C1MaskedTextBox control. The prompt character defined that text that will appear in the control to prompt the user to enter text. The prompt character indicates to the user that text can be entered, and can be used to detail the type of text allowed. By default the underline "_" character is used.

    Note that the TextMaskFormat property must be set to IncludePrompt or IncludePromptAndLiterals for prompt characters to be used. If you do not want prompt characters to be used, set TextMaskFormat to IncludeLiterals or ExcludePromptAndLiterals.

    You can customize the default Prompt Character at design time, in XAML, and in code.

    To set the PromptChar property add Mask="0000" PromptChar="#" to the <c1:C1MaskedTextBox> tag so that it appears similar to the following:

    XAML
    Copy Code
    <c1:C1MaskedTextBox Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="C1MaskedTextBox1" VerticalAlignment="Top" Width="120" Mask="0000" PromptChar="#"></c1:C1MaskedTextBox>
    

     

    To set the PromptChar property add the following code to your project:

    Visual Basic
    Copy Code
    Dim x As Char = "#"c
    C1MaskedTextBox1.Mask = "0000"
    C1MaskedTextBox1.PromptChar = x
    

     

    C#
    Copy Code
    char x = '#';
    this.c1MaskedTextBox1.Mask = "0000";
    this.c1MaskedTextBox1.PromptChar = x;
    

     

    To set the PromptChar property at run time, complete the following steps:

    1. Click the C1MaskedTextBox control once to select it.
    2. Navigate to the Properties window and enter "0000" in the text box next to the Mask property to set a mask.
    3. In the Properties window, enter "#" (the pound character) in the text box next to the PromptChar property

     

    Run your project and observe:

    The pound character will appear as the prompt in the control. In the following image, the number 32 was entered in the control: