ANAT2403
asked on
cancel event SelectedIndexChanged
In VS2005 winforms C# I have a combobox . In the selected indexchange event I want to save the old value and not to update to the new value.How do I do it?
ASKER
Hi,
This is not bad exept from one problem:
It enter the selectedindexchanged event for one emore time and if I ask a question in this
event about the condition, this question is raised twice and I don't like it.
Anat
This is not bad exept from one problem:
It enter the selectedindexchanged event for one emore time and if I ask a question in this
event about the condition, this question is raised twice and I don't like it.
Anat
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you want to cancel the SelectedIndexChanged the next time, you can simply revert the value to the one that's stored in the variable.
E.g.:
public partial class Form1 : Form
{
int oldIndex = -1;
private void comboBox1_SelectedIndexCha
{
if (yourCondition)
{
oldIndex = comboBox1.SelectedIndex;
}
else
{
if (oldIndex != -1)
{
comboBox1.SelectedIndex = oldIndex;
}
}
}
}