SelectedIndexChanged Event raises by filling Combobox?

  • Thread starter Thread starter Thomas Bandt
  • Start date Start date
T

Thomas Bandt

Hi,

I am a little bit confused: I have in my test application a
Combobox-Control which has a SelectedIndexChanged event
registered:

this.listMaschinenart.SelectedIndexChanged += new
System.EventHandler(this.listMaschinenart_SelectedIndexChanged);

By initializing the form I fill the ComboBox with data from
SQL Server. The same procedure is called with SelectedIndexChanged.

Because I was wondering of the low speed at initializing I placed
a MessageBox into the filling method. Result: the MessageBox is
shown at least twice. I think this is caused by firing the
SelectedIndexChanged event by filling data (by DataSet by the way)
into the combobox.

Can anybody explain me why the event is fired in this case?

Greetings, Thomas
 
The solution: setting the event handler after initializing
the combobox data.

Greetings, Thomas
 
Back
Top