GridViewMaskBoxColumn format problem

4 posts, 0 answers
  1. George
    George avatar
    62 posts
    Member since:
    Sep 2008

    Posted 24 Apr 2015 Link to this post

    Hi, I am using a GridViewMaskBoxColumn to edit and display a 12 character long string as follows: "AAAA-AAAA-AAAA"

    I am using standard mask type and mask as  ">LLLL-LLLL-LLLL"  which forces all input characters to uppercase.

    The editor works fine when inputing the string in the cell, displaying correctly the prompt characters ("_") and seperation literals ("-").

    However, the text after editing is finished appears in the grid as "AAAAAAAAAAAA" instead of the desired "AAAA-AAAA-AAAA" of the mask format, which incidently is the default behavior of the maskededitbox editor I use in other parts of my application.

    Can you please suggest why the desired text format behavior of the maskededitbox is not implemented in the gridview, or a way to go around this problem?

     

    Regards,

     

    George

     

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 29 Apr 2015 Link to this post

    Hello George,

    Thank you for writing.

    I suppose that the GridViewMaskBoxColumn.TextMaskFormat property is set to MaskFormat.ExcludePromptAndLiterals on our end. When it is set to IncludePromptAndLiterals the result is as expected. Please refer to the attached screenshot illustrating the behavior on my end. I have also attached my sample project for your convenience.

    I hope this information helps. Should you have further questions, I would be glad to help.
     
    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. George
    George avatar
    62 posts
    Member since:
    Sep 2008

    Posted 29 Apr 2015 in reply to Dess Link to this post

    Thanks for coming back,Iam afraid the example you have attached works only in the case that there is no initial data loaded to the grid. I have revised your example (I am afraid I cannot attach it to this post) to load some initial data to the list and the situation I have described still persists.

    Regards,

    George

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 04 May 2015 Link to this post

    Hello George,

    Thank you for writing back.

    Note that the Mask property is a string of characters that constrains the user input, not the value set programmatically by the developer. GridViewMaskBoxColumn uses RadMaskedEditBox as an editor, but this editor is not initialized when adding rows programmatically. Hence, if the cell value does not match the mask, after activating the editor, its value will be empty. One possible solution is to include "-" when adding the rows (e.g. "AAAA-AAAA-AAAA"). An alternative option is to simulate value changing by using the editor. Thus, you will force the editor to validate its value according to the Mask:
    private void RadForm1_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < 4; i++)
        {
            this.radGridView1.Rows.Add("AAAAAAAAAAAA");
        }
        foreach (GridViewRowInfo r in this.radGridView1.Rows)
        {
            this.radGridView1.GridNavigator.Select(r, this.radGridView1.CurrentColumn);
            this.radGridView1.BeginEdit();
            object initialValue = this.radGridView1.ActiveEditor.Value;
            this.radGridView1.ActiveEditor.Value = null;
            this.radGridView1.EndEdit();
            this.radGridView1.BeginEdit();
            this.radGridView1.ActiveEditor.Value = initialValue;
            this.radGridView1.EndEdit();
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
Back to Top