This is a migrated thread and some comments may be shown as answers.

GridViewMaskBoxColumn format problem

3 Answers 106 Views
GridView
This is a migrated thread and some comments may be shown as answers.
George
Top achievements
Rank 1
George asked on 24 Apr 2015, 01:24 PM

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

 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 29 Apr 2015, 08:03 AM
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.

 
0
George
Top achievements
Rank 1
answered on 29 Apr 2015, 09:48 AM

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

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 May 2015, 06:33 AM
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.

 
Tags
GridView
Asked by
George
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
George
Top achievements
Rank 1
Share this question
or