DataGridViewHelper GetColumnIndex Method CleanCode C# Libraries v1.2.03 API
Converts a column name in a OnlineDataGridView to a column index.

Namespace: CleanCode.Forms
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public static int GetColumnIndex(
	DataGridView dataGridView,
	string columnName
)

Return Value

Column index matching the column name, or -1 if not found.
Remarks

Converts either the internal name (the DataPropertyName property) or the display name (the Name property) to a column index. This provides a failsafe way to reference Cells in a DataGridView, since referencing by name (e.g. dgv.Row[i].Cells[columnName]) may fail unless the Name happens to equal the DataPropertyName.
See Also