Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Whenever we add data source to combobox with code below.

comboBoxBusNo.DataSource = busNo.Tables[0];
            comboBoxBusNo.DisplayMember = "BusId";
            comboBoxBusNo.ValueMember = "Id";

Why
private void comboBoxBusNo_SelectedIndexChanged(object sender, EventArgs e)
event is called. How we can stop this to be called at loading.
Posted

1 solution

Hi Chetan Saini

Whenever you bind the data to any control, what is does is re-initialize the index and values. That's why it fires this selectedindexchange event.
 
Share this answer
 
Comments
Chetan Saini 1-Apr-14 3:23am    
How to stop calling select index change event on load.
Er. Puneet Goel 1-Apr-14 5:41am    
this is default behavior, if you want to set the selected index as it was selected before load, you can save the value to some hidden label and once bounded then reassign that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900