Thanks for Greg's quick response!
Hi Brian,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need the second combobox on the
form displays items according to child rows of the first combobox. If there
is any misunderstanding, please feel free to let me know.
I agree with Greg's suggestion to use GetChildRows on a DataRelation
object. It's better to use a typed DataSet for convenience. We can handle
the SelectedValueChanged event of the first combobox to change items in the
second one. Here I have written a code snippet for your reference. HTH.
private void Form1_Load(object sender, System.EventArgs e)
{
SqlDataAdapter sda1 = new SqlDataAdapter("SELECT * FROM Customers",
this.sqlConnection1);
SqlDataAdapter sda2 = new SqlDataAdapter("SELECT * FROM Orders",
this.sqlConnection1);
sda1.Fill(dataset11.Customers);
sda2.Fill(dataset11.Orders);
this.comboBox1.DisplayMember = "CompanyName";
this.comboBox1.ValueMember = "CustomerID";
this.comboBox1.DataSource = dataset11.Customers;
this.comboBox2.DisplayMember = "OrderDate";
this.comboBox2.ValueMember = "OrderID";
}
private void comboBox1_SelectedValueChanged(object sender,
System.EventArgs e)
{
if(this.comboBox1.SelectedValue != null)
{
this.comboBox2.DataSource =
dataset11.Customers.FindByCustomerID(this.comboBox1.SelectedValue.ToString()
).GetChildRows(dataset11.Relations["CustomersOrders"]);
}
}
If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."