Hello,
I am creating a mobile 5 application using CF 3.5.
I have a combo box that keeps on firing the SelectionIndexChanged event. I need this event to get an item from the combo box. However, when the combo datasource is set it will fire this. I have resolved the issue with a simple bool test. See code below. However I have noticed that when debugging the event often fires. Its hard to track down what is causing this to fire.
Code Snippet
//Set to false to prevent pre-firing of selectValue changed event before datasource is set.
this.cboDataSourceSet = false;
this.cboRecentNumbers.DataSource = this.bsRedialedNumbers;
this.cboRecentNumbers.DisplayMember = "Name";
this.cboRecentNumbers.ValueMember = "ID";
this.cboDataSourceSet = true;
And in the event itself
Code Snippet
private void cboRecentNumbers_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.cboDataSourceSet)
{
//Do something here
}
}
I am thinking of 2 methods to solve this:
1) is there a way to stop the event from firing only when you need it to. (maybe a way to track down where it is being fired)
2) Inherit from the combo box and add your own custom SelectionChanged event. (anyone point me in the right direction?).
I would perfer method 2 as I have never done that before, and good to learn some thing new.
Many thanks,
Steve