Hello,
I am creating a mobile 5 application using CF 3.5.
I have a combo box that keeps on firing on 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 this issue with a simple bool test. See code below. However, I have noticed that the event often fires. Its hard to track down what is causing this to fire.
I am thinking of 2 methods to solve this issue:
1) Is there a way to stop the event being fired or a way to track down the event to find what other conditions are causing it to fire?
2) Inherit from the combo box class and add your own SelectionChanged Event. (Can anyone point me in the right direction for doing something like this?).
I would perfer method 2 as I have never done anything like that before. So good for learning something new.
Many thanks for any suggestion and help with this,
Steve
I am creating a mobile 5 application using CF 3.5.
I have a combo box that keeps on firing on 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 this issue with a simple bool test. See code below. However, I have noticed that the event often fires. Its hard to track down what is causing this to fire.
Code:
//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;
Code:
private void cboRecentNumbers_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.cboDataSourceSet)
{
//Do something here.
}
}
I am thinking of 2 methods to solve this issue:
1) Is there a way to stop the event being fired or a way to track down the event to find what other conditions are causing it to fire?
2) Inherit from the combo box class and add your own SelectionChanged Event. (Can anyone point me in the right direction for doing something like this?).
I would perfer method 2 as I have never done anything like that before. So good for learning something new.
Many thanks for any suggestion and help with this,
Steve