I have ListBox control(WinForm project).
When I bind DataSource to the ListBox control listBox_SelectedIndexChanged event is fired.
Here is the code:
public Form1() { InitializeComponent();
string conn ="consntring";
SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Colors", conn);
DSColors dataSetcColors = new DSColors();
adapter.Fill(dataSetcColors.Colors);
listBox1.DisplayMember = "ColorName";
listBox1.ValueMember = "ColorID";
listBox1.DataSource = dataSetcColors.Colors;
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Any idea how to prevent listBox_SelectedIndexChanged event when DataSource is bound?