GridviewMaskboxColumn Maxlength

7 posts, 1 answers
  1. Majid
    Majid avatar
    5 posts
    Member since:
    Jun 2011

    Posted 10 Apr 2012 Link to this post

    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
  2. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 12 Apr 2012 Link to this post

    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 >>
  3. Majid
    Majid avatar
    5 posts
    Member since:
    Jun 2011

    Posted 12 Apr 2012 Link to this post

    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
  4. Answer
    Don
    Don avatar
    60 posts
    Member since:
    Aug 2010

    Posted 12 Apr 2012 Link to this post

    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.
  5. Majid
    Majid avatar
    5 posts
    Member since:
    Jun 2011

    Posted 12 Apr 2012 Link to this post

    Hi Don

    Thanks for your solution! 
    That works pretty well
  6. Don
    Don avatar
    60 posts
    Member since:
    Aug 2010

    Posted 12 Apr 2012 Link to this post

    Glad to hear it, Majid! :-)
  7. Peter
    Admin
    Peter avatar
    1148 posts

    Posted 17 Apr 2012 Link to this post

    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 >>
Back to Top