I am trying to write user friendly messages for when data integrity rules are broken in a DataGridView. I have handled the DataError error as per the code below but it does something odd when reading the column index of the DataGridViewDataErrorEventArgs. e.ColumnIndex = 2 but the e.Exception refers to the column at ColumnIndex = 3!

VB Code:
  1. Private Sub AssetDataGridView_DataError(ByVal sender As Object, _
  2.                                           ByVal e As DataGridViewDataErrorEventArgs) Handles AssetDataGridView.DataError
  3.  
  4.     '  Get column name and header text from sender
  5.  
  6.     Dim colName As String = CType(sender, DataGridView).Columns(e.ColumnIndex).DataPropertyName
  7.     Dim headerText As String = CType(sender, DataGridView).Columns(e.ColumnIndex).HeaderText
  8.  
  9.     '  Now replace column name with user-friendly header name
  10.     Dim excMessage As String = e.Exception.Message

E.g. ? e.Exception.Message
"Column 'LocationID' does not allow nulls."
but
? colName
"AssetTypeID"

Not sure why this is happening - any help greatly appreciated.