Datagridview RowHead SetNumber

Datagridview RowHead SetNumber

        private void P_gv_setRowNumber(DataGridView dgv)
        {
            foreach (DataGridViewRow row in dgv.Rows)
            {
                //row.HeaderCell.Value = row.Index + 1;

                row.HeaderCell.Value = (row.Index + 1).ToString();
            }
            dgv.RowHeadersWidth = 50;
            dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
        }