I am using VB.NET 2005 with the DataGridView control called grdSODetail. After the user enters a value in the Cust P/N grdSODetail column; I would like to retrieve the Cust P/N value using one of the DataGridViewCell events. The following code does not work because the CellValidating event is not able to set the Cust P/N column value in time to retrieve the value and returns the following error:
Null Reference; Object Reference Not Set to an Instance of an Object.
My code is as follows:
Private Sub grdSODetail_CellValidating(ByVal sender As Object, _
ByVal e As DataGridViewCellValidatingEventArgs) _
If String.IsNullOrEmpty(e.FormattedValue.ToString()) = False Then
sCustPN = grdSODetail.Rows(iRow).Cells("Cust P/N").Value.ToString
Can anyone suggest a DataGridView event I can use to run my code and retrieve the value of the Cust P/N column value? Or perhaps something else to make this work?