Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

Set Combobox Value based on field value from other dataset

$
0
0

Hi folks,

I have a grid showing customerID and customer name from a 'CUSTOMERS' dataset. 

On the other side of the form I have textboxes that are bound to the same dataset. I have address, town etc. As I select the different customers from the grid each textbox changes its value as expected.

I also have a comboxbox which is populated with country names from the "COUNTRIES" dataset. In the CUSTOMERS dataset there is a field called countryID. 

I want it so when I select a customer from the CUSTOMERS DataSet and say the countryID is 'FR' then I want the combobox selected item to change to 'France'. Whatever the underying country code is the Customer Dataset, I want to show the Name of the country from the Countries dataset.

Here is how I have set up the countries combobox:

cmbCountry.DisplayMember = "Name";	// Shows List of Country Names
cmbCountry.ValueMember = "countryID";   // Field in the datatable which I want to be the value of the combobox
cmbCountry.DataSource = countryDataSet.Tables[0];

I'm guessing that the code for this needs to be "something" like follows:

private void CustomerGrid_SelectionChanged(object sender, EventArgs e)
{

  //  update combos
      cmbCountry.SelectedItem = CustomersDataset....column["countryID"]


}

But I just cant figure it out ??

Hope my question makes sense!

J


jppnn



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>