Datagrid cellvalidating event

You should get a nasty looking error message on your screen. However, it's ugly, so you want to give the user a friendly message. You are interested in displaying a friendly error message for your first and second columns. Net arrays are zero based, so this would be Columns 0 & 1. Show("You must enter a valid decimal.") Case 1 'Needs to be a datetime Message Box. Just remember--don't get too caught up in the syntax at first.

Show("You must enter a valid datetime.") End Select This is basically saying that you've got a data entry error, and depending on the column with the error, you want to display a custom message. It sometimes helps to take a step back and look at the big picture of what you're trying to accomplish. Net can be hard to work with sometimes because it has so many libraries. Ok my code is commented out in the cell validation. I have data in the datagrid is has been loaded from the I go to the blank line I can't enter anything.

However, if a cell enters edit mode and then leaves edit mode with no changes, the formatted value from our function is applied.

For example, if you were to add a new row and type "1" in the cell, our format function would convert that to "00001.00", and if you put a breakpoint in the above code, you would see that both Vendors. Value and the vend Num variable would reflect this formatted value. Any idea what's going on here or how to correct it?

I have "Enable adding" checked and everything else unchecked.

Could I have something not set properly in the Edit Columns? I see how this works now - and I can put the validation inside the case statements.. I know you are here to help guide people to their answers but today turned into a whole lesson.

But if I tab and select enter on one of the existing lines I do get the datagridview default error dialog with all the messy info you talked of.

I do have a visual basic 2005 - wrox book and 2 programing in visual basic books by Bradley and Millspaugh which I refer to alot. ----------------------------------------------------But just a little info on my situation.As far as books go, Wrox books are usually pretty good. Eventually, it will all come together, especially once you figure out which objects are subclassed from others. I also tried selecting the add button in the navigator that was automatically created.It creates a new blank line and I still can't add anything.Although I would like to understand this better than I do.routine, and try to add a word into your decimal field of your Data Grid View, and navigate off the record. Column Index Case 0 'Needs to be a decimal Message Box.

Leave a Reply