vendredi 13 mars 2015

Simple Combobox in Winforms - Firing twice (Use mouse to expand combobox and select a item using keyboard)

Consider a very basic form with a simple combo box



public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.comboBox1.Items.Add("test1");
this.comboBox1.Items.Add("test2");
this.comboBox1.Items.Add("test3");
}

private void Form1_Load(object sender, EventArgs e)
{
this.comboBox1.SelectedIndexChanged += (o, args) =>
{
MessageBox.Show("Combo box changed!");
};
}
}


I have even changed the eventhandler to the below code. (Based on the linked question. Still the same problem)



this.comboBox1.SelectedValueChanged += (o, args) =>
{

MessageBox.Show("Combo box changed!");
};


Expand the dropdown using mouse and select any item using keyboard.


The combo-box fires twice (The message box appears twice)


Any ideas why?


Aucun commentaire:

Enregistrer un commentaire