Reputation: 672
I Create a function NewLoad() and call it in butto1_click. And i have event listBox1_SelectedIndexChanged which called itself during operation function "NewLoad"
private void button1_Click(object sender, EventArgs e)
{
NewLoad();
}
private void NewLoad()
{
String text = textBox1.Text.Trim();
textBox1.Text = text;
oleDbSelectCommand1.Parameters[0].Value = text;
dataSet11.Clear(); <<<--- call listbox1_SelectedIndexChanged
oleDbDataAdapter1.Fill(dataSet11);
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
dataSet21.Clear();
}
why this happens and how i can to avoid it?
Upvotes: 0
Views: 45
Reputation: 631
If you have something selected in list box 1, when you clear it, the selected index will change, thus raising selection changed event.
Upvotes: 0
Reputation: 887449
My psychic debugging skills tell me that the listbox is databound to the dataset.
When you clear your dataset, the listbox is emptied, and the selection changes. This raises the relevant event.
Upvotes: 3