Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#3.0 WinForm
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 24-Dec-12 17:11pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 Maciej Los 169
4 /\jmot 169
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100