G
Guy Dillen
I want to relate 2 listBoxes. Although during the filling of the first
listBox1; the event SelectedIndexChanged already fires (this is not the
purpose). The event should only fire when a select an item in listBox1.
How can i avoid that the event fires too early?
....
private void button3_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataAdapter da = null;
string SQLcom = "SELECT toto, id FROM table";
da = new DataAdapter(SQLcom, conn);
da.Fill(ds, "table");
listBox1.DataSource = ds.Tables["table"];
listBox1.ValueMember = "id";
listBox1.DisplayMember = "toto";
listBox1.SelectedIndex = -1;
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
DataSet ds = new DataSet();
DataAdapter da = null;
string SQLcom = "SELECT tata, id FROM table2";
da = new DataAdapter(SQLcom, conn);
da.Fill(ds, "table2");
listBox2.DataSource = ds.Tables["table2"];
listBox2.ValueMember = "id";
listBox2.DisplayMember = "tata";
listBox2.SelectedIndex = -1;
}
listBox1; the event SelectedIndexChanged already fires (this is not the
purpose). The event should only fire when a select an item in listBox1.
How can i avoid that the event fires too early?
....
private void button3_Click(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
DataAdapter da = null;
string SQLcom = "SELECT toto, id FROM table";
da = new DataAdapter(SQLcom, conn);
da.Fill(ds, "table");
listBox1.DataSource = ds.Tables["table"];
listBox1.ValueMember = "id";
listBox1.DisplayMember = "toto";
listBox1.SelectedIndex = -1;
}
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
DataSet ds = new DataSet();
DataAdapter da = null;
string SQLcom = "SELECT tata, id FROM table2";
da = new DataAdapter(SQLcom, conn);
da.Fill(ds, "table2");
listBox2.DataSource = ds.Tables["table2"];
listBox2.ValueMember = "id";
listBox2.DisplayMember = "tata";
listBox2.SelectedIndex = -1;
}