Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm getting user's selected item in SelecttionChangeCommitted method with the selected index of the combobox,but i fond the SelecttionChangeCommitted method will execute before the method SelectedIndexChanged,so i got a incorrect result course of the incorrect index.The SelectedIndexChanged method will execute a few times when binding the datasource and any property else,so i just cann't use the SelectedIndexChanged method,and should i deal with it,what's your idea?Thanks.
Posted

1 solution

Hi,

As per my understanding from you above comments, I assume that the SelectedIndexChanged event is being fired multiple times while binding the DataSource. Here, you can always apply below condition to stop executing the rest of the code.
C#
if (SelectedIndex > 0)


Also, set the ComboBox's property - DropDownStyle = DropDownList, instead of any other thing.

And for using SelectedIndexChanged vs SelectionChangeCommited, this below link will explain you one of the scenarios where you might get an error.

here[^]

There will be more differences (check here)[^], but please do let us know if you have any other concerns.

Merry Christmas..!

Regards,
Vamsi
 
Share this answer
 

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