Frederico Eglesias
Frederico Eglesias

Reputation: 55

How to make one choice depend on the choice of another?

I have a problem with DataGridViewComboBoxColumn. I have two of those and when I'm selecting something in one, then I would like to see only things which related to that one.

enter image description here

My code:

public Form1()
{
    InitializeComponent();

    List<string> contactNames = accountNamez.Select(s => (string)s).ToList();
   
    dataGridView1.ColumnCount = 2;
    dataGridView1.Columns[0].Name = "Product ID";
   
    DataGridViewComboBoxColumn cmb = new DataGridViewComboBoxColumn();
    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.DataSource = data;
    dataGridView1.Columns.Add(cmb2);e
}

Do I need to make some event handler? I'm new to it. I'm not sure how to make relations between two lists with DRVComboBoxColumn.

Upvotes: 0

Views: 64

Answers (0)

Related Questions