GridViewTextBoxColumn Only Numbers Allowed

4 posts, 0 answers
  1. Ramasamy
    Ramasamy avatar
    2 posts
    Member since:
    Oct 2012

    Posted 23 Sep 2013 Link to this post

    Hello,

    I am using Radgridview and i have N number of Columns. While doing Add/Edit a row, on a particular column user should allow only numbers(0 to 10) to type/fill. The user can also copy paste on this cell/column in that case it should only allow to paste numbers.
    Can any one help me on this?

    Thanks & Regards
    Rams
  2. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 26 Sep 2013 Link to this post

    Hi Ramasamy,

    Thank you for writing back.

    The best way for you to achieve this behavior will be to use GridViewDecimalColumn. This way you will be able to set Мaximum and Мinimum value. Also if the user pasteс bigger or smaller value the cell value would be rounded when the cell is in edit mode. For the case where the cell is not in edit mode and you paste in it, you can use the Pasting event to handle it.

    I hope this will be useful. Should you have further questions, I would be glad to help.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Ramasamy
    Ramasamy avatar
    2 posts
    Member since:
    Oct 2012

    Posted 27 Sep 2013 Link to this post

    Hi Dimitar,

    Thanks for the reply. I have already tried the GridViewDecimalColumn and could't get the desired outcome. If we use the GridViewDecimalColumn it round off with decimal places, I have already tried with out decimal places as well with GridViewDecimalColumn

    May be some sample would be helpful. Can you provide some validation sample to allow only number in the GridViewTextColumn/GridViewDecimalColumn?

    Thanks & Best Regards
    Ramasamy.P

     
  4. Dimitar
    Admin
    Dimitar avatar
    2913 posts

    Posted 02 Oct 2013 Link to this post

    Hello Ramasamy,

    Thank you for writing back.

    What I think will be suitable for you case will be to use combination of GridViewMaskBoxColumn and some extra validation in the CellValidating event. This way you will always have appropriate values in this column. Please refer to the attached project.

    I hope this helps. Should you have any other questions do not hesitate to ask.

    Regards,
    Dimitar
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top