0
When I go to check the following code, there is nothing in any of the ComboBoxes
. For me, everything is normal, I see nothing wrong, what can be?
public FormExemplo()
{
ExemploList = new List<string[]>;
CmbB.Enabled = false;
}
private void AttCmbA(ComboBox A)
{
A.Items.Clear();
for (i = 0; i < ExemploList.Count; i++)
{
A.Items.Add(ExemploList[i][0]);
}
}
private void AttCmbB(ComboBox A, ComboBox B)
{
B.Items.Clear();
for (int i = 0; i < ExemploList.Count; i++)
{
if (A.SelectedItem.Equals(ExemploList[i][0]))
{
for (int j = 0; j < 3; j++)
{
CmbB.Add(ExemploList[i][j]);
}
}
}
}
private void CmbA_SelectedIndexChanged(object sender, EventArgs e)
{
CmbB.Enabled = true;
AttCmbB(CmbA, CmbB);
}
private List<string[]> ExemploList;
private void Btn_Click(object sender, EventArgs e)
{
for (int i = 0; i < 10; i++)
{
ExemploList.Add(new string[3] { (2 * i).ToString(), (2 * (i++)).ToString(), (2 * (i * i).ToString() });
}
AttCmbA(CmbA);
}
I tested your code with two
comboboxes
and a button to callAttCmb()
and worked as expected, the twocomboboxes
were filled with "Example". Was the end result supposed to be different? What is the code calling? I’m assuming the way the methods are declared was only for SOPT and not so in the code.– Omni
Now it’s exactly the same.
– ptkato