3

The issue is that the SelectedIndexChanged event is called both when the user makes the change and when the change is made by the application code setting SelectedItem.

Is there a way to tell if the item was changed by the direct actions of the user from the mouse or keyboard?

1

1 Answer 1

1

Try something like this SelectedChangeCommitted MSDN

private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
{

    ComboBox comboBox = (ComboBox) sender;

    // Change the length of the text box depending on what the user has 
    // selected and committed using the SelectionLength property.
    if (comboBox.SelectionLength > 0)
    {
        textbox1.Width = 
            comboBox.SelectedItem.ToString().Length *
            ((int) this.textbox1.Font.SizeInPoints);
        textbox1.Text = comboBox.SelectedItem.ToString();
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.