baabaa_nl
asked on
VB.Net, Catch "DataGridView Default Error Dialog" Exception
Hi Experts,
I am using VB.Net and datagridview.
In my gridview I have got three columns. And in the second and third column I have set the format to currency.
The main problem is, if there was any error raised, an DataGridView Default Error Dialog box is shown. But to avoid that error dialog box , data error Event is used.
But what I need is that I need to catch that error in a try catch block, but I don't know where to put the try catch block to catch the error.
The error occurs when I leave a cell blank and move to another cell
I am using VB.Net and datagridview.
In my gridview I have got three columns. And in the second and third column I have set the format to currency.
The main problem is, if there was any error raised, an DataGridView Default Error Dialog box is shown. But to avoid that error dialog box , data error Event is used.
But what I need is that I need to catch that error in a try catch block, but I don't know where to put the try catch block to catch the error.
The error occurs when I leave a cell blank and move to another cell
set a defaut value for the column where the cell belongs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i tried that code, and it was eliminating the check box. but wat i need is to catch that error my self using a try catch block, but i dont know where to put the try catch block
put a check for the respective column before applying the code!
Else you will need to put your try-catch in the CellEndEdit event
Else you will need to put your try-catch in the CellEndEdit event
ASKER
I didn't understand the first part of your comment about
>>put a check for the respective column before applying the code!
Also i was using DataError Event, and not the CellEndEdit Event.
Also, i tried using a try catch block for the CellEndEdit event, but it didnt make use of it, it was as if the try catch block was ignored.
>>put a check for the respective column before applying the code!
Also i was using DataError Event, and not the CellEndEdit Event.
Also, i tried using a try catch block for the CellEndEdit event, but it didnt make use of it, it was as if the try catch block was ignored.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi CodeCruiser,
I really don't know from which part of the code the exception is raised, but the only way to stop it is by using the dataerror event.
But the main problem is, the exception is due to many reason, one could be due to a null value and other due to incorrect double format and many more. but in order for me to specifically to catch the exception, I require the try catch block, but I don't know where to put it.
so is there anyway that I could find the cause of the reason of the exception on the dataerror event.
This may sound really false, but I feel that the error is raised from the designer code? Is that possible.
Thanks in advance.
I really don't know from which part of the code the exception is raised, but the only way to stop it is by using the dataerror event.
But the main problem is, the exception is due to many reason, one could be due to a null value and other due to incorrect double format and many more. but in order for me to specifically to catch the exception, I require the try catch block, but I don't know where to put it.
so is there anyway that I could find the cause of the reason of the exception on the dataerror event.
This may sound really false, but I feel that the error is raised from the designer code? Is that possible.
Thanks in advance.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.