Datagridview cellvalidating

Rated 4.89/5 based on 746 customer reviews

column, its value is tested for validity by checking that it is not empty. If the event handler for the Cell Validating event finds that the value is an empty string, the Data Grid View prevents the user from exiting the cell until a non-empty string is entered.

Dim adapter As New Sql Data Adapter(select Command, connection String) Dim data As New Data Table() data. Storing sensitive information, such as a password, within the connection string can affect the security of your application.

In my case, Cell Value Changed has done what I wanted/needed.

EDIT The biggest thing about the Cell Validating event is that you can stop the user from leaving a cell, if the value entered does not pass your validation.

Now, since so many books use the Cell Validating event, I wonder if there is not any gotcha (in display for example) with using the Cell Value Changed?

I understand that the impact in performance should be irrelevant when using simple validation and conditional highlighting rules but I would as much prefer it not to run useless code everytime the user moves to another cell if it can be avoided.

Leave a Reply