How to Use Enums instead of column index in C#

Viewed 504

i am trying to use Enum as a Datagridview Coloumn index, but failed

My Enums

enum _EnmDgvCol
    {
        SrNo,
        Name,
        Qty,
        Rate,
        Amount,
    }

and I am trying to as follows:

MydataGridView[_EnmDgvCol.Name, 0].Value = "Some Value";

but its giving Error

The best overloaded method match for 'System.Windows.Forms.DataGridView.this[int, int]' has some invalid arguments

if i use following code its works

MydataGridView[1, 0].Value = "Some Value";

My Question is How to Use Enums instead of column index

4 Answers
Related