I have experienced this same problem in the past and have
resolved the issue by using a no-so-elegant but workable
solution using a module level boolean variable.
For example, declare a variable in your form as such...
Private mboolSettingDataSource As Boolean = False
Then prior to setting the DataSource property set the
variable to True then after setting the DataSource
property set the variable back to False.
Then at the begining of the SelectedIndexChanged event
place a code snipet like...
If mboolSettingDataSource Then
Exit Sub
End If
FWIW: I believe the reason the SelectedIndexChanged event
fires multiple times is because internally the DataSource
property actually changes the SelectedIndex porperty
(probably once for each element in the array).
I hope this helps!
-----Original Message-----
hi,
i am using a ListBox control on a windows form using
VB.Net. when iset the DataSource property of the control to an
ArrayList it firesfollowing events in this order:
SelectedIndexChanged
SelectedIndexChanged
DataSourceChanged
SelectedIndexChanged
is there any way to check in SelectedIndexChanged event
handler thatif event is fired while setting DataSource property or
user hasactually changed the item? SelectedIndex property doesn't
work 'causeit is already set to '0'.
BTW, why SelectedIndexChanged is fired 3-times?
Any help...
Thanks
TF
.