0

I have a datagrid with 2 columns: 1 is normal textbox type and the other column is combobox type.

My user interface has another datagrid_1 which contains a list of names. When a user clicks on the row of datagrid_1 with names. It puts the value selected by the user in the row of datagrid_2 in 1st column and then expects user to select one of the values in the other column (combobox).

I am not sure how to assign a datasource to this combobox. I have tried the following code but I am getting error "Datagridview_2 combox value is not valid."

var source = new BindingSource();                                    
var phase_7 = (phaseeqType.return_Distinct_Phase()
       .Select(b => b).AsEnumerable()).ToList();

string[] P_combo = new string[phase_7.Count()];
for (int i = 0; i < phase_7.Count(); i++)
{
   P_combo[i] = phase_7.ToString();
}

source.DataSource = phase_7; 
dataGridView1.CurrentRow.Cells[1].Value = source;

Can anyone pls help?

UiUx
  • 967
  • 2
  • 14
  • 25
user7
  • 133
  • 3
  • 3
  • 11

1 Answers1

0

Cells don't have a DataSource property, so you would have try casting it to something that does:

Example:

((DataGridViewComboBoxCell)dataGridView1.CurrentRow.Cells[1])
    .DataSource = source;
LarsTech
  • 80,625
  • 14
  • 153
  • 225