Datagrid cell's Numeric Validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buterfly0707
    New Member
    • Nov 2009
    • 30

    Datagrid cell's Numeric Validation

    I want validate a separate cells in datagrid. if i want only numbers in a particular cell in the datagrid how can i do it.

    for example :

    There is datagrid with 3 columns. ID,Name,Phone number

    I want to validate this phone number field. if user enter a some other values than a number i want to give a error message.

    This may be a easy task as im very new to c# please someone help me with this problem.
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    if you're using Datagrid view you can trace the cell being edited through the datagrid view's Cell Value Changed Event


    And the you can validate in as well

    Comment

    • buterfly0707
      New Member
      • Nov 2009
      • 30

      #3
      i
      f you're using Datagrid view you can trace the cell being edited through the datagrid view's Cell Value Changed Event


      And the you can validate in as well
      Yes, im using Datagrid view. im sorry, what i wanted to know is how to do this validation part??
      Can you tell me how i can validate the particular cell value. i mean the method??

      thanks

      Comment

      • ThatThatGuy
        Recognized Expert Contributor
        • Jul 2009
        • 453

        #4
        Code:
        DataGridViewCell dg = dataGridView1.Rows[e.RowIndex].Cell[e.ColumnIndex];
                    dg.Value
        put up this code in your cell value changed event and then validate the value retrieved

        Comment

        • buterfly0707
          New Member
          • Nov 2009
          • 30

          #5
          Thank You : ThatThatGuy

          Comment

          Working...