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");

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!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.