Need VB.net Help - Data Grid View Validating

Discussion in 'Programming' started by guy123, Apr 21, 2010.

  1. #1
    Hey
    I need help with the data grid view control in VB.NET. I need to validate data input so it's <100 and >0. Also, need to restrict letters from being inputted. If anyone could help, please get in touch ASAP. It's a very very very small data set and your time will be rewarded.
     
    guy123, Apr 21, 2010 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    There are problems trying to implement cell by cell validation using the grid's Validating event architecture. The problem is that the grid is not the object handling the data. Instead, a TextBox or some other control is the control managing the changing of the cell contents. One way to implement the validation at the grid level is to handle the CurrentCellChanged event, and if the previous cell's value is not proper, then return to that cell. You can download a sample that implements this process. The sample only handles the validation from cell to cell movement. If you want to handle the validation when the user clicks on the forms Close button, then you would have to add a special event handler for this and do one last validation at this point.
     
    kmap, Apr 21, 2010 IP