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

GridviewMaskboxColumn Maxlength

6 Answers 114 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Majid
Top achievements
Rank 1
Majid asked on 10 Apr 2012, 07:55 AM
Hi everyone,
I am using radGrid to exibit information of people! one of the fields is Mobile that is thought to be Numeric and limited digits. So I am using GridviewMaskboxColumn by following code :

GridViewMaskBoxColumn mobileColumn = new GridViewMaskBoxColumn();
            mobileColumn.HeaderText = "Mobile#";
            mobileColumn.MaxLength = 10;
            mobileColumn.FieldName = "MobileNo";
            mobileColumn.MaskType = MaskType.Numeric;
            mobileColumn.Mask = "G";
            grid.Columns.RemoveAt(10);
            grid.MasterTemplate.Columns.Insert(10, mobileColumn);

Everything's fine but The Maxlength doesn't work! I mean when you want to edit MobileNo, you can enter digits more than 10!
Any ideas?!

Thanks

6 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 12 Apr 2012, 04:00 PM
Hi Majid,

Thank you for writing.

The MaxLength property is valid only for MaskType None. For other types of masks (Numeric for example), the Mask property has higher priority than MaxLength - for example mask "n3" means unlimited digits before decimal separator and 3 digits after it; "g" mean unlimited numbers.

Do not hesitate to contact us if you have other questions.

All the best,

Peter
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Majid
Top achievements
Rank 1
answered on 12 Apr 2012, 04:46 PM
Hi Peter and thanks for reply

Let me tell you what I need for this field.
As I mentioned above, I have a mobile field which has to be numeric and limited to 10 digits. Plus, I don't want to have separator between digits. How can I handle it?!

Thanks
0
Accepted
Don
Top achievements
Rank 1
answered on 12 Apr 2012, 05:12 PM
If it is up to 10 digits you can use a mask of 9999999999, which should make all of the digits optional. If you need at least some of the digits to be entered just replace some of the 9s with 0s (zeroes). The 0 makes the digit mandatory. I believe this would work as either a numeric or standard mask.
0
Majid
Top achievements
Rank 1
answered on 12 Apr 2012, 07:17 PM
Hi Don

Thanks for your solution! 
That works pretty well
0
Don
Top achievements
Rank 1
answered on 12 Apr 2012, 07:28 PM
Glad to hear it, Majid! :-)
0
Peter
Telerik team
answered on 17 Apr 2012, 03:14 PM
Hi Don,

Thank for sharing your experience with the community.

I updated your Telerik point for the community effort.

Greetings,
Peter
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Majid
Top achievements
Rank 1
Answers by
Peter
Telerik team
Majid
Top achievements
Rank 1
Don
Top achievements
Rank 1
Share this question
or