Index Alias

DGV Framework will display the row index (Number) if you set the alias to #

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using DGV.Framework;

namespace csDemo
{
    public partial class Form1 : Form
    {
        public class User
        {
            public string Name { get; set; }
            public int Age { get; set; }
            public string Gender { get; set; }

            public Contacts Contacts { get; set; }

           

        }

        public class Contacts
        {
            public string Email { get; set; }
            public string Phone { get; set; }


        }

        public Form1() => InitializeComponent();


        private void Form1_Load(object sender, EventArgs e)
        {
            //create sample the records
            List<User> usersList = new List<User>();
            for (int i = 0; i < 10; i++)
            {
                usersList.Add(new User
                {
                    Age = 28,
                    Name = "Kim Too FLex",
                    Gender = "Male",
                    Contacts = new Contacts()
                    {
                        Email = "[email protected]",
                        Phone = "+1 800 000 000"
                    }
                });
            }

            //set position column
            _dataGridView.SetColumnAlias("Pos", "#");
           
            //Bind the list to datagrid view
            _dataGridView.Bind(usersList);
        }
    }
}

Last updated

Was this helpful?