Datagridview validating event
This results in the Row Validating handler pulling a null value from the Unbound column (because Cell Formatting hasn't been called and set the value yet).I was refreshing my knowledge on the DGV and thought that handling the Cell Value Needed event may be the ticket but setting Data Grid View Cell Value Event Args.Experts, How do I trigger the Data Grid View Validating event from an external event like a Button Press? I want to Validate the cells when the user clicks a Button outside the User Control. When I click on the Save Menu item on the main form, I want the contents to be validated and then saved to a file. private void Test But_Click(object sender, Event Args e) private void Grid View_Cell Validating(ob I have a group of custom user control which contain Data Grid View.This was not intentional, it's REALLY old code that had complicated parsing and formatting requirements and I incorrectly implemented a solution based on an unbound column.I now know the correct way to handle this and have since fixed my code, however I'd still like to know how I could have solved the bug another way.
The situation is that I have a DGV control that is bound to a List of business objects.
Close Connection) With m_Bindingsrc Detail While RFIDReader.
End Edit() End While End With grddetails is the name of grid, m_Bindingsrc Detail is datasource for grd Details According to This , You should be able to force the validation trigger using Begin Edit and End Edit. I am fetching Product description, MRP and other details in cell validating.
This all works fine when the user is editing and adding rows through UI interaction, but creates a problem when the Data Source is set.
The issue appears to be that Cell Formatting is not called when the DGV updates it's internal list and builds the rows, or at least it's not called before the validating event is fired.
I handle the Row Validating event and do one final validation on the row as a whole to ensure everything is cool.