Some event handlers for the WinForm DataGridView
have DataGridViewCellEventArgs
as a parameter and a ColumnIndex
as a property of that argument.
ColumnIndex
is a number representing the column's ordinal #.
Is there a way to reference a column name from that argument instead of column index?
So instead of doing:
if (e.ColumnIndex == 1)
I prefer something like:
if (e.ColumnName == "CustomerName")
because if a column changes its position, it will break the code.