I am desperately trying to add a DataGridViewComboBoxColumn to my DataGridView programatically. Here is the Code I've got so far.

DataTable dt = new DataTable();
    dt = _userBL.getUsersTable().DefaultView.ToTable(false, "Person_ID", "FirstName", "LastName", "Title", "Username");
    dataGridView1.DataSource = dt;

    DataGridViewComboBoxColumn ComboBoxCell = new DataGridViewComboBoxColumn();
    ComboBoxCell.Name = "State";
    ComboBoxCell.ValueMember = "State";//ComboBoxCell.DisplayMember = "State";
    ComboBoxCell.DisplayMember = "State"; 
    ComboBoxCell.DataSource = _userBL.getUsersTable().DefaultView.ToTable(false, "State");
    this.dataGridView1.Columns.Add(ComboBoxCell);

But i get no data in the comboboxcolumn, and since I added DataSource, I cannot add items (Active,Inactive) in it. Also, when I click it a small dropdown should appear, even for empty comboboxes, but it does not.
Thanks in advance!

Edited 2 Years Ago by tanatos.daniel

My code works, but because i had my datagridview,editmode = editprogramatically, i couldn't access dropdown list.

This question has already been answered. Start a new discussion instead.