C# All my combobox are changing text

Asked

Viewed 40 times

2

I’m having a problem with my program where when I change the values of one of my combobox, example:

private void Ex1Mat_SelectedIndexChanged(object sender, EventArgs e)
{
    if (start == false)
    {
        SqlDataAdapter Ex1UpdateAss = new SqlDataAdapter("select Assunto, id from dbo.Assuntos where Materia = " + Ex1Mat.Text + "", conex);
        Ex1UpdateAss.Fill(AssTable);
        Ex1Ass.DataSource = AssTable;
        Ex1Ass.DisplayMember = AssTable.Columns[0].ColumnName;
        Ex1Ass.ValueMember = AssTable.Columns[1].ColumnName;
    }
}

all change their DisplayMembers which in case was to change only one.

Do you have any idea what this is?

  • You have several combobox on your screen and when you call selectedindexchanged they all change too ? (other combos?) that’s it?

1 answer

1

It is possible that you have accidentally selected all Comboboxes when creating the event. In this case Visualstudio attaches the event code that should be on a single combobox to all those that were selected at the time. To get this, you will need the Designer.Cs code of the form in question. Take a look to see if the Selectindexchanged event of all of them is pointing to the same method.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.