I have two lists and two ComboBoxes. So, I would like to make a relation between them. That means, when you choose from box1 something, then you can choose only some options in box2, which is related to box1.
Notice:
I'm not creating ComboBox in GUI, I'm using code. It's looking like this:
Question:
I need to get value when the user chose something in my ComboBox. How can I get the user's choice?
Code:
DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
cmb.Name = "Accounts";
List<string> data = new List<string>();
foreach (var item in contactNames)
{
data.Add(item);
}
cmb.DataSource = data;
dataGridView1.Columns.Add(cmb);
//dataGridView1.Rows.Add(data);
DataGridViewComboBoxColumn cmb2 = new DataGridViewComboBoxColumn();
List<String> contacts2 = new List<String>();
cmb2.Name = "Contacts";
cmb2.DataSource = data;
dataGridView1.Columns.Add(cmb2);