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?

Bryan
  • 2,870
  • 24
  • 39
  • 44
Ian Ringrose
  • 51,220
  • 55
  • 213
  • 317
  • This question may help http://stackoverflow.com/questions/3263240/how-to-stop-a-comboboxs-selectedindexchanged-event-from-firing-when-the-form-lo – 26071986 Aug 03 '12 at 14:31

1 Answers1

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();
    }
}
MethodMan
  • 18,625
  • 6
  • 34
  • 52