Vb net datagrid cellvalidating

All of the rows in the first column of this file need to be checked upon loading so that the length of its contents will be exactly 17 characters.

Here's what I've come up with: Suppose I load a file with a row that has 18 characters (or anything different than 17).

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.

For information about building this example from the command line for Visual Basic or Visual C#, see Building from the Command Line or Command-line Building With You can also build this example in Visual Studio by pasting the code into a new project.

I have a datagrid that is populated with an Excel File.It may be skipping over the If block In a simple test I did, it didn't seem to interfere, but I do agree that in a case like this I would rather get the errortext instead of a messagebox popping up. Or is that the way with lots of code and work x D ? In my initial test to achieve what the OP was asking for, I did notice however that I was not able to close the form when on a cell that was incorrect. Private Sub Data Grid View1_Data Error(By Val sender As Object, _ By Val e As Data Grid View Data Error Event Args) _ Handles Data Grid View1.Show("Please Enter a numeric Value") 'This will change the number back to original Data Grid View1.

Leave a Reply