I am assuming that you are setting the selected index of the combo box so that it matches some default value, e.g. editing some sort of record.
The easiest way is to remove the event handler before the change and add if back afterwards.
Assuming that the combobox is called
comboBox1
and that the event handler is called
comboBox1_SelectedIndexChanged
then this should do the job.
using System.Collections.Generic;
using System.Windows.Forms;
namespace sample
{
public partial class Form1 : Form
{
private List<string> _items = new List<string>() { "One", "Two" };
public Form1()
{
InitializeComponent();
DataBind();
}
private void DataBind()
{
comboBox1.SelectedIndexChanged -= this.comboBox1_SelectedIndexChanged;
comboBox1.DataSource = _items;
int selectedIndex = 1;
comboBox1.SelectedIndex = selectedIndex;
comboBox1.SelectedIndexChanged += this.comboBox1_SelectedIndexChanged;
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
MessageBox.Show("fired");
}
}
}</string></string>