SelectedIndexChanged Event raises by filling Combobox?

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
 
T

Thomas Bandt

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

Greetings, Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top